What does poll() do with a timeout of 0?

前端 未结 3 2495
自闭症患者
自闭症患者 2021-02-19 21:02

I\'m looking at the poll() man page, and it tells me the behavior of poll() when positive and negative values are passed in for the timeout parameter.

3条回答
  •  北海茫月
    2021-02-19 21:33

    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,

提交回复
热议问题