Without this fix it will create zombies that might cause deadlocks, especially when respawned from the inittab and it dies because of a signal (e.g. ‘killall -9 runsvdir').
Installing a simple SIGCHLD-handler makes the problem go away. Signed-off-by: Markus Gothe <[email protected]> diff --git a/runit/runsvdir.c b/runit/runsvdir.c index 11ab40a..dca2232 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c @@ -232,6 +232,15 @@ static NOINLINE int do_rescan(void) return need_rescan; } +static void signal_child(int sig UNUSED_PARAM){ + /* reap children if we die */ + for (;;) { + pid_t pid = wait_any_nohang(NULL); + if (pid <= 0) + break; + } +} + int runsvdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int runsvdir_main(int argc UNUSED_PARAM, char **argv) { @@ -269,6 +278,11 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) */ | (i_am_init ? ((1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGINT)) : 0) , record_signo); + + /* Install child-handler for reaping children. */ + bb_signals(0 + + (1 << SIGCHLD) + , signal_child); svdir = *argv++; #if ENABLE_FEATURE_RUNSVDIR_LOG @@ -369,12 +383,14 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv) #endif { unsigned deadline = (need_rescan ? 1 : 5); + sig_block(SIGCHLD); #if ENABLE_FEATURE_RUNSVDIR_LOG if (rplog) poll(pfd, 1, deadline*1000); else #endif sleep(deadline); + sig_unblock(SIGCHLD); } #if ENABLE_FEATURE_RUNSVDIR_LOG --------------1.9.5 (Apple Git-50.3)--
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
