kqueue() and O_NONBLOCK

女生的网名这么多〃 提交于 2019-12-06 05:24:24

If you use kqueue(), should you set O_NONBLOCK on your file descriptors?

Nope.

In other words, does kqueue() guarantee that the next I/O operation on a ready file descriptor will not block, regardless of whether O_NONBLOCK is set?

Yep.

You do not need to. However, I generally do as a sanity check. This makes operations like read() return -1 and set errno to EWOULDBLOCK. I would much rather get an EWOULDBLOCK and know that my implementation of kqueue is buggy than have read() calls block (and therefore my program freeze) for unknown reasons.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!