]> git.ipfire.org Git - thirdparty/man-pages.git/commit
poll.2: Set fd to its bitwise complement to ignore
authorDavid Ward <david.ward@gatech.edu>
Mon, 6 Jun 2022 03:31:39 +0000 (23:31 -0400)
committerAlejandro Colomar <alx.manpages@gmail.com>
Mon, 6 Jun 2022 14:12:51 +0000 (16:12 +0200)
commit17411a0f7b3148ec39aac8f12ee77f2118ac7e80
tree08d98a56d7eccbfffb7bfaf13a5033589c74a362
parent8a7c2ab937d3e97ba7ea053ad1db73accae54c03
poll.2: Set fd to its bitwise complement to ignore

A valid file descriptor will be non-negative, i.e., 0 <= fd <= INT_MAX.
When all of the bits of a valid file descriptor are flipped, the result
is a negative value: ~0 = -1, ~1 = -2, ..., ~INT_MAX = INT_MIN. If all
of these bits are flipped again, then the file descriptor is recovered.

Negating the file descriptor does not quite achieve this, because there
will be no change for fd 0. (Likewise, negating INT_MIN would not cause
any change in value, but it is never a valid file descriptor.)

Link: https://bugzilla.kernel.org/show_bug.cgi?id=79411
Signed-off-by: David Ward <david.ward@gatech.edu>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
man2/poll.2