From 148458e0a1fd25e167aa2ef229d1c9a70b27c3e9 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Thu, 11 Aug 2011 09:34:51 -0700 Subject: Use SIG_IGN instead of a do-nothing handler for signal events with kqueue --- kqueue.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'kqueue.c') diff --git a/kqueue.c b/kqueue.c index b0772dc1..dc61ae39 100644 --- 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); -- cgit v1.2.1