From 70b939ecd382cbc9142887a8efe7f49e211d0940 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Tue, 11 Feb 2014 11:33:44 +0000 Subject: [PATCH] So, it turns out SIGCHLD is discarded by default, so we have to set up a dummy handler to make it interrupt an ioctl(2) or select(2). This makes those short-lived ctld(8) zombies disappear. Sponsored by: The FreeBSD Foundation --- usr.sbin/ctld/ctld.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index c5f5771d51b..27e790cee9f 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1741,6 +1741,17 @@ sigterm_handler(int dummy __unused) sigterm_received = true; } +static void +sigchld_handler(int dummy __unused) +{ + + /* + * The only purpose of this handler is to make SIGCHLD + * interrupt the ISCSIDWAIT ioctl(2), so we can call + * wait_for_children(). + */ +} + static void register_signals(void) { @@ -1763,6 +1774,11 @@ register_signals(void) error = sigaction(SIGINT, &sa, NULL); if (error != 0) log_err(1, "sigaction"); + + sa.sa_handler = sigchld_handler; + error = sigaction(SIGCHLD, &sa, NULL); + if (error != 0) + log_err(1, "sigaction"); } int