kevent behavior

Ivan Radovanovic radovanovic at gmail.com
Thu Mar 19 06:33:10 UTC 2015


Hi guys,

Is there defined (and guaranteed) behavior of kevent if kqueue FD is 
being closed while blocking kevent call is in progress?

Possible scenario would be like this:

Thread 1:
...
kfd = kqueue();
...
// create second thread afterwords
// and do blocking wait for events
result = kevent(kfd, changelist, nchanges, eventlist, nevents, NULL);
if (result == -1)
	// check if there was request to stop listening for events


Thread 2:
// do something
// then close kqueue's fd
close(kfd);


I am asking this because file watcher implementation for mono is 
implemented that way (which I find nicer than using timeout), but this 
is apparently based on expected kevent behavior under Darwin, and I 
can't find any mention that in FreeBSD kevent is going to behave the 
same way (at least not on kqueue(2) manual page)

Kind regards,
Ivan


More information about the freebsd-hackers mailing list