Here are some issues to be aware of when using this library under any platform:
int main() { int kqfd; struct kevent kev; kqfd = kqueue(); signal(SIGUSR1, SIG_IGN); EV_SET(&kev, SIGUSR1, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); kevent(kqfd, &kev, 1, NULL, 0, NULL); }
There are additional considerations listed below that are platform-specific.
There are several compatibility issues to be aware of when using this library under Linux:
"The select(2) and poll(2) system calls currently do not respect the SO_RCVLOWAT setting on Linux, and mark a socket readable when even a single byte of data is available. A subsequent read from the socket will block until SO_RCVLOWAT bytes are available."
Here are the issues to be aware of when using this library under Solaris:
# usermod -K defaultpriv=basic,proc_clock_highres $user
There are some differences in the behavior of the kevent(2) system call across the various BSD-based operating systems. Here are some of the differences to be aware of:
Here are the steps to use libkqueue in your program if you use an ordinary Makefile:
If your program uses the GNU Autoconf/Automake/Libtool build system, the following steps will allow you to use libkqueue:
# # Prefer native kqueue(2); otherwise use libkqueue if present. # AC_CHECK_HEADER(sys/event.h, [], [PKG_CHECK_MODULES(KQUEUE, libkqueue)] )
foo_CFLAGS+=$(KQUEUE_CFLAGS) foo_LDADD+=$(KQUEUE_LIBS)
Instead of using the $(KQUEUE_LIBS) variable, you could just add libkqueue.la to your programs LDADD variable.
libkqueue uses one or more helper threads, so all programs that link with libkqueue must also link against the pthreads library. Calls to kqueue() and kevent() are safe to be used from multiple threads.