]> granicus.if.org Git - libevent/commitdiff
Use SIG_IGN instead of a do-nothing handler for signal events with kqueue
authorZack Weinberg <zackw@panix.com>
Thu, 11 Aug 2011 16:34:51 +0000 (09:34 -0700)
committerNick Mathewson <nickm@torproject.org>
Tue, 30 Aug 2011 19:33:02 +0000 (15:33 -0400)
kqueue.c

index b0772dc13f008ceed208a09740d21663531dd70f..dc61ae3969f9d97a0f27f0fd6ea902343c66089a 100644 (file)
--- a/kqueue.c
+++ b/kqueue.c
@@ -164,12 +164,6 @@ err:
        return (NULL);
 }
 
-static void
-kq_sighandler(int sig)
-{
-       /* Do nothing here */
-}
-
 #define ADD_UDATA 0x30303
 
 static void
@@ -432,9 +426,13 @@ kq_sig_add(struct event_base *base, int nsignal, short old, short events, void *
        if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1)
                return (-1);
 
-       /* XXXX The manpage suggest we could use SIG_IGN instead of a
-        * do-nothing handler */
-       if (_evsig_set_handler(base, nsignal, kq_sighandler) == -1)
+        /* We can set the handler for most signals to SIG_IGN and
+         * still have them reported to us in the queue.  However,
+         * if the handler for SIGCHLD is SIG_IGN, the system reaps
+         * zombie processes for us, and we don't get any notification.
+         * This appears to be the only signal with this quirk. */
+       if (_evsig_set_handler(base, nsignal,
+                               nsignal == SIGCHLD ? SIG_DFL : SIG_IGN) == -1)
                return (-1);
 
        return (0);