Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -742,10 +742,12 @@ AC_CHECK_FUNC(kqueue, [ AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue]) AC_SUBST(OFKERNELEVENTOBSERVER_KQUEUE_M, "OFKernelEventObserver_kqueue.m") + + AC_CHECK_FUNCS(kqueue1) ]) AC_CHECK_HEADER(poll.h, [ AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h]) AC_SUBST(OFKERNELEVENTOBSERVER_POLL_M, "OFKernelEventObserver_poll.m") Index: src/OFKernelEventObserver_kqueue.m ================================================================== --- src/OFKernelEventObserver_kqueue.m +++ src/OFKernelEventObserver_kqueue.m @@ -43,13 +43,24 @@ - init { self = [super init]; @try { +#ifdef HAVE_KQUEUE1 + if ((_kernelQueue = kqueue1(O_CLOEXEC)) == -1) + @throw [OFInitializationFailedException + exceptionWithClass: [self class]]; +#else + int flags; + if ((_kernelQueue = kqueue()) == -1) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; + + if ((flags = fcntl(_kernelQueue, F_GETFD, 0)) != -1) + fcntl(_kernelQueue, F_SETFD, flags | FD_CLOEXEC); +#endif _changeList = [[OFDataArray alloc] initWithItemSize: sizeof(struct kevent)]; _removedArray = [[OFMutableArray alloc] init];