是否有一个 kqueue()/kevent() 相当于 select() 的“errorfds”集?

Jer*_*ner 5 error-handling select kqueue

今天我将一些代码从 select() 移植到 kqueue(),我注意到 kevent() 似乎没有 select() 的“异常设置”功能的模拟。

也就是说,select()的函数签名是:

int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict errorfds, struct timeval *restrict timeout);
Run Code Online (Sandbox Code Playgroud)

...对于 kevent(),EVFILT_READ 对应于 (readfds),EVFILT_WRITE 对应于 (writefds),但我没有看到任何像 EVFILT_ERROR 对应于 (errorfds) 的内容。

kevent() 下是否真的不支持套接字错误条件,或者是否存在但以某种对我来说不明显的方式实现?

Ism*_*eno 0

不可能以这种方式进行过滤。您必须根据标志 (EV_EOF) 和 fflags 手动对传入事件进行分类。