From 008c9d0036e348242e323c0b5a66f3724b4a839d Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Mon, 5 Nov 2018 21:35:00 -0600 Subject: supervise-daemon: reap zombies We need to make sure to reap zombies so that we can shut down successfully. Fixes #252. Possibly related to #250. --- src/rc/supervise-daemon.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/rc') diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 883c738d..52525c19 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -197,6 +197,16 @@ static void healthcheck(int sig) do_healthcheck = 1; } +static void reap_zombies(int sig) +{ + int serrno; + (void) sig; + + serrno = errno; + while (waitpid((pid_t)(-1), NULL, WNOHANG) > 0) {} + errno = serrno; +} + static char * expand_home(const char *home, const char *path) { char *opath, *ppath, *p, *nh; @@ -457,6 +467,7 @@ static void supervisor(char *exec, char **argv) signal_setup_restart(SIGPIPE, handle_signal); signal_setup_restart(SIGALRM, handle_signal); signal_setup(SIGTERM, handle_signal); + signal_setup(SIGCHLD, reap_zombies); signal_setup_restart(SIGUSR1, handle_signal); signal_setup_restart(SIGUSR2, handle_signal); signal_setup_restart(SIGBUS, handle_signal); -- cgit v1.2.3