What does poll() do with a timeout of 0?
As I see it, waiting for a timeout means "having" a timeout. This way I would expect that poll() actually checks the file descriptors, and then waits if no one is ready to a timeout of 0 milliseconds (no wait at all). But the case is that it will just signal if a fd is available.
I also checked linux source code and to my knowledge, this is the way it works: first calculates the "future" waiting point, then checks the file descriptors, then if none available, waits for the timeout specified time.
Regards,
It will return immediately:
If timeout is greater than zero, it specifies a maximum interval (in milliseconds) to wait for any file descriptor to become ready. If timeout is zero, then
poll()
will return without blocking. If the value of timeout is-1
, thepoll
blocks indefinitely.
, as of Mac OS X 10.5
;
Maximum interval to wait for the poll to complete, in milliseconds. If this value is 0,
poll()
will return immediately. If this value isINFTIM (-1)
,poll()
will block indefinitely until a condition is found.
, as of OpenBSD 3.8