diff options
author | William Hubbs <w.d.hubbs@gmail.com> | 2018-11-05 21:35:00 -0600 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2018-11-05 21:35:00 -0600 |
commit | 008c9d0036e348242e323c0b5a66f3724b4a839d (patch) | |
tree | f29a81314433131c99fa457328ebb6603c9af678 /src | |
parent | 025c9693ccab9c6220520ace47aa81553e7ea600 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/rc/supervise-daemon.c | 11 |
1 files changed, 11 insertions, 0 deletions
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); |