echo "#define HAVE_SPAWN_H" >>$CONFIG_H
fi
+if [ -z "$POLL" ]; then
+ printf "Testing for kqueue1 ... "
+ cat <<EOF >_kqueue.c
+#include <sys/event.h>
+int main(void) {
+ return kqueue1(0);
+}
+EOF
+ if $XCC _kqueue.c -o _kqueue 2>&3; then
+ POLL=kqueue1
+ echo "yes"
+ else
+ echo "no"
+ fi
+ rm -f _kqueue.c _kqueue
+fi
if [ -z "$POLL" ]; then
printf "Testing for kqueue ... "
cat <<EOF >_kqueue.c
rm -f _pselect.c _pselect
fi
case "$POLL" in
+kqueue1)
+ echo "#define HAVE_KQUEUE" >>$CONFIG_H
+ echo "#define HAVE_KQUEUE1" >>$CONFIG_H
+ ;;
kqueue)
echo "#define HAVE_KQUEUE" >>$CONFIG_H
;;
#if defined(HAVE_KQUEUE)
#include <sys/event.h>
+#include <fcntl.h>
#ifdef __NetBSD__
/* udata is void * except on NetBSD */
#define UPTR(x) ((intptr_t)(x))
TAILQ_INIT(&ctx->free_timeouts);
ctx->exitcode = EXIT_FAILURE;
#ifdef HAVE_KQUEUE
+#ifdef HAVE_KQUEUE1
+ if ((ctx->kqueue_fd = kqueue1(O_CLOEXEC)) == -1) {
+ free(ctx);
+ return NULL;
+ }
+#else
if ((ctx->kqueue_fd = kqueue()) == -1) {
free(ctx);
return NULL;
}
+ if ((i = fcntl(ctx->kqueue_fd, F_GETFD, 0)) == -1 ||
+ fcntl(ctx->kqueue_fd, F_SETFD, i | FD_CLOEXEC) == -1)
+ {
+ close(ctx->kqueue_fd);
+ free(ctx);
+ return NULL;
+ }
+#endif
/* There is no sigmask parameter to kqueue, instead
* we have to use it's filters. */
ctx->fds_len = 0;