When you create a kqueue with kqueue()
you get back a file descriptor. But it appears that this file descriptor cannot be meaningfully polled with select()
. I understand that the standard way to poll/read from a kqueue()
is with kevent(...)
but I'm trying to integrate with some legacy code that polls file descriptors using select()
.
The goal here was to be able to fire a "user event" that can be detected by this select
-based polling mechanism (even if the event eventually needs to be "consumed" using kevent()
later). This looked like the kind of thing EVFILT_USER
was born to do, but a quick experiment indicates that select()
doesn't report the kqueue's fd as being ready to read when an event is added (and triggered) in the kqueue, it just times out (or blocks forever). (But an equivalent kevent()
call does see/return the event.)
Am I doing something wrong? Or is it just not possible to poll a kqueue's fd with select()
?
The paper, describing kqueue/kevent says (sect 6.5):
This is indeed the case for FreeBSD, i've checked this with following code: