From 21e20cb4ad106b9d49ff24652a5cd47380905d4d Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Fri, 4 Jan 2008 15:10:47 +0000 Subject: [PATCH] =?UTF-8?q?init:=20wait=20for=20orphaned=20children=20too?= =?UTF-8?q?=20while=20waiting=20for=20sysinit-like=20processes=20(Harald?= =?UTF-8?q?=20K=C3=BCthe=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init/init.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/init/init.c b/init/init.c index 68a59d88e..f7eb8f34b 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;