mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: LKML <linux-kernel@vger.kernel.org>,
	Michael Kerrisk <mtk.manpages@googlemail.com>,
	linux-man@vger.kernel.org
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: poll never return EBADF?
Date: Tue, 26 May 2009 18:09:32 +0900 (JST)	[thread overview]
Message-ID: <20090526175622.687B.A69D9226@jp.fujitsu.com> (raw)

Hi

I have one stupid question.

"man poll" describe this error code.

>ERRORS
>       EBADF  An invalid file descriptor was given in one of the sets.

but current kernel implementation ignore invalid file descriptor,
not return EBADF.


================ cut code ========================================
static inline unsigned int do_pollfd(struct pollfd *pollfd, poll_table *pwait)
{
        unsigned int mask;
        int fd;

        mask = 0;
        fd = pollfd->fd;
        if (fd >= 0) {					//// here
                int fput_needed;
                struct file * file;

                file = fget_light(fd, &fput_needed);
                mask = POLLNVAL;
                if (file != NULL) {			//// and here
                        mask = DEFAULT_POLLMASK;
                        if (file->f_op && file->f_op->poll)
                                mask = file->f_op->poll(file, pwait);
                        /* Mask out unneeded events. */
                        mask &= pollfd->events | POLLERR | POLLHUP;
                        fput_light(file, fput_needed);
                }
        }
================ end code ========================================

In the other hand, SUSv3 talk about 

> POLLNVAL
>    The specified fd value is invalid. This flag is only valid in the
>    revents member; it shall ignored in the events member.

and

> If the value of fd is less than 0, events shall be ignored, and revents 
> shall be set to 0 in that entry on return from poll().

but, no desribe EBADF.
(see http://www.opengroup.org/onlinepubs/009695399/functions/poll.html)

So, I think the implementation is correct.


Why don't we remove EBADF description?




             reply	other threads:[~2009-05-26  9:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26  9:09 KOSAKI Motohiro [this message]
2009-06-02  4:45 ` Michael Kerrisk
2009-06-02  4:49   ` Michael Kerrisk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090526175622.687B.A69D9226@jp.fujitsu.com \
    --to=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®