All of lore.kernel.org
 help / color / mirror / Atom feed
* poll never return EBADF?
@ 2009-05-26  9:09 ` KOSAKI Motohiro
  0 siblings, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-05-26  9:09 UTC (permalink / raw)
  To: LKML, Michael Kerrisk, linux-man; +Cc: kosaki.motohiro

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?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* poll never return EBADF?
@ 2009-05-26  9:09 ` KOSAKI Motohiro
  0 siblings, 0 replies; 6+ messages in thread
From: KOSAKI Motohiro @ 2009-05-26  9:09 UTC (permalink / raw)
  To: LKML, Michael Kerrisk, linux-man-u79uwXL29TY76Z2rM5mHXA
  Cc: kosaki.motohiro-+CUm20s59erQFUHtdCDX3A

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: poll never return EBADF?
@ 2009-06-02  4:45   ` Michael Kerrisk
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk @ 2009-06-02  4:45 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-man

Hello Motohiro,

On Tue, May 26, 2009 at 11:09 AM, KOSAKI Motohiro
<kosaki.motohiro@jp.fujitsu.com> wrote:
> Hi
>
> I have one stupid question.

It doesn't look stupid to me...

> "man poll" describe this error code.
>
>>ERRORS
>>       EBADF  An invalid file descriptor was given in one of the sets.

This text seems to have been added in man-pages-1.39 (around 2000),
but with no explanation or note on authorship. I suspect someone was
confused.

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

Which is what I understand it should do.

> ================ 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().

Exactly.

> but, no desribe EBADF.
> (see http://www.opengroup.org/onlinepubs/009695399/functions/poll.html)
>
> So, I think the implementation is correct.

Agreed.

> Why don't we remove EBADF description?

Yes, that seems corrrrect for me. I've removed it for the next release (3.22).

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: poll never return EBADF?
@ 2009-06-02  4:45   ` Michael Kerrisk
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk @ 2009-06-02  4:45 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-man-u79uwXL29TY76Z2rM5mHXA

Hello Motohiro,

On Tue, May 26, 2009 at 11:09 AM, KOSAKI Motohiro
<kosaki.motohiro-+CUm20s59erQFUHtdCDX3A@public.gmane.org> wrote:
> Hi
>
> I have one stupid question.

It doesn't look stupid to me...

> "man poll" describe this error code.
>
>>ERRORS
>>       EBADF  An invalid file descriptor was given in one of the sets.

This text seems to have been added in man-pages-1.39 (around 2000),
but with no explanation or note on authorship. I suspect someone was
confused.

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

Which is what I understand it should do.

> ================ 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().

Exactly.

> but, no desribe EBADF.
> (see http://www.opengroup.org/onlinepubs/009695399/functions/poll.html)
>
> So, I think the implementation is correct.

Agreed.

> Why don't we remove EBADF description?

Yes, that seems corrrrect for me. I've removed it for the next release (3.22).

Cheers,

Michael


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: poll never return EBADF?
@ 2009-06-02  4:49     ` Michael Kerrisk
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk @ 2009-06-02  4:49 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-man

>> Why don't we remove EBADF description?
>
> Yes, that seems corrrrect for me. I've removed it for the next release (3.22).

And I forgot to say: thanks for the very detailed bug report!

Cheers,

Michael
-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: poll never return EBADF?
@ 2009-06-02  4:49     ` Michael Kerrisk
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Kerrisk @ 2009-06-02  4:49 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-man-u79uwXL29TY76Z2rM5mHXA

>> Why don't we remove EBADF description?
>
> Yes, that seems corrrrect for me. I've removed it for the next release (3.22).

And I forgot to say: thanks for the very detailed bug report!

Cheers,

Michael
-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git
man-pages online: http://www.kernel.org/doc/man-pages/online_pages.html
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-02  4:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-26  9:09 poll never return EBADF? KOSAKI Motohiro
2009-05-26  9:09 ` KOSAKI Motohiro
2009-06-02  4:45 ` Michael Kerrisk
2009-06-02  4:45   ` Michael Kerrisk
2009-06-02  4:49   ` Michael Kerrisk
2009-06-02  4:49     ` Michael Kerrisk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.