diff options
author | Denis Vlasenko | 2008-01-04 15:10:47 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-01-04 15:10:47 +0000 |
commit | 21e20cb4ad106b9d49ff24652a5cd47380905d4d (patch) | |
tree | bf568707e67d1857dc844dbdddbd18e57fe06ad4 /init/init.c | |
parent | 4dada747e54b11f05db1beda3f4653ffe432255c (diff) | |
download | busybox-21e20cb4ad106b9d49ff24652a5cd47380905d4d.zip busybox-21e20cb4ad106b9d49ff24652a5cd47380905d4d.tar.gz |
init: wait for orphaned children too while waiting
for sysinit-like processes (Harald Küthe <harald-tuxbox@arcor.de>)
Diffstat (limited to 'init/init.c')
-rw-r--r-- | init/init.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/init/init.c b/init/init.c index 68a59d8..f7eb8f3 100644 --- a/init/init.c +++ b/init/init.c @@ -97,10 +97,16 @@ static const char *const environment[] = { static void delete_init_action(struct init_action *a); static void halt_reboot_pwoff(int sig) ATTRIBUTE_NORETURN; -/* TODO: move to libbb? */ -static int waitfor(pid_t runpid) +static void waitfor(pid_t pid) { - return safe_waitpid(runpid, NULL, 0); + /* waitfor(run(x)): protect against failed fork inside run() */ + if (pid <= 0) + return; + + /* Wait for any child (prevent zombies from exiting orphaned processes) + * but exit the loop only when specified one has exited. */ + while (wait(NULL) != pid) + continue; } static void loop_forever(void) ATTRIBUTE_NORETURN; |