poll never return EBADF?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?



--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux