bug-hurd
[Top][All Lists]
Advanced

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

Re: Code for testing hurdselect.c


From: Svante Signell
Subject: Re: Code for testing hurdselect.c
Date: Thu, 18 Oct 2012 14:33:53 +0200

On Thu, 2012-10-18 at 13:27 +0200, Samuel Thibault wrote:
> Svante Signell, le Thu 18 Oct 2012 11:43:04 +0200, a écrit :
> > Remember: This was written a long time ago, why making a big issue of
> > it?
> 
> > 
> > POSIX does not specify to return EBAFD for the POLL case as for the
> > SELECT case. That's it. 
> 
> That's what was completely missing in your description...
> 
> So EBADF would have to go through POLLERR? It's not clear in the norm: 
> 
> POLLERR
>         An error has occurred on the device or stream.
> 
> EBADF means the device or stream doesn't even exist, since the
> descriptor is invalid. So it seems like POSIX does not specify the
> behavior, and thus the current Hurd behavior is correct, and it's
> ntpdate which needs to be fixed into not passing an invalid descriptor.

I don't interpret the POSIX text that way.

Return values are:
Upon successful completion, poll() shall return a non-negative value. A
positive value indicates the total number of file descriptors that have
been selected (that is, file descriptors for which the revents member is
non-zero). A value of 0 indicates that the call timed out and no file
descriptors have been selected. Upon failure, poll() shall return -1 and
set errno to indicate the error.

with errors specified by:

ERRORS
        The poll() function shall fail if:
        [EAGAIN]
                The allocation of internal data structures failed but a
                subsequent request may succeed.
        [EINTR]
                A signal was caught during poll().
        [EINVAL]
                The nfds argument is greater than {OPEN_MAX}, [XSR]
                [Option Start] or one of the fd members refers to a
                STREAM or multiplexer that is linked (directly or
                indirectly) downstream from a multiplexer. [Option End]

The output code however is in the revent member of the pollfd struct: 

POLLERR
        An error has occurred on the device or stream. This flag is only
        valid in the revents bitmask; it shall be ignored in the events
        member.
POLLHUP
        The device has been disconnected. This event and POLLOUT are
        mutually-exclusive; a stream can never be writable if a hangup
        has occurred. However, this event and POLLIN, POLLRDNORM,
        POLLRDBAND, or POLLPRI are not mutually-exclusive. This flag is
        only valid in the revents bitmask; it shall be ignored in the
        events member.
POLLNVAL
        The specified fd value is invalid. This flag is only valid in
        the revents member; it shall ignored in the events member.

Specifically, my interpretation of POLLNVAL is that it should be
reported for each invalid fd given as input.

And my interpretation of POLLERR is that it should be reported to
_every_ fd (device or stream) given as input. 

And for these cases the return code should be the number of good fds as
well as bad fds, since the revents member is nonzero. (I did not come
that far in my changes by then, but it could easily be done with today's
knowledge! There are also other case to take care of like: POLLWRBAND
etc)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]