Bug 79411 - poll() fd negation trick doesn't work for fd 0
Summary: poll() fd negation trick doesn't work for fd 0
Status: RESOLVED CODE_FIX
Alias: None
Product: Documentation
Classification: Unclassified
Component: man-pages (show other bugs)
Hardware: All Linux
: P1 low
Assignee: documentation_man-pages@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-02 13:19 UTC by Nadav Har'El
Modified: 2014-07-10 05:28 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Nadav Har'El 2014-07-02 13:19:39 UTC
poll(2) contains the following paragraph:

       The  field  fd  contains  a  file descriptor for an open file.  If this
       field is negative, then the corresponding events field is  ignored  and
       the revents field returns zero.  (This provides an easy way of ignoring
       a file descriptor for a  single  poll()  call:  simply  negate  the  fd
       field.)

The negation technique described here will work with one important assumption - that fd 0 isn't one of the polled descriptors. This will normally be the case (fd 0 will be stdin and not be polled), but it doesn't strictly have to be this way. I think this needs to be pointed out. Perhaps say:

        (This provides an easy way of ignoring a file descriptor for a  single  poll()  call:  simply  negate  the  fd field. This technique will not work if one of the polled fd is 0).

Issue discovered by Avi Kivity.
Comment 1 Nadav Har'El 2014-07-10 05:28:27 UTC
Fixed in man-pages-3.70 release.

Note You need to log in before you can comment on or make changes to this bug.