From 1cc17b2f2fe93fdf71ffb650c6013b7560dd2d2f Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 17 Mar 2021 11:27:00 -0700 Subject: init: fix waitforpid(). The kill(2) should be checking whether `pid` still exists, not the process that wait(2) just told us has exited. --- toys/pending/init.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'toys/pending') diff --git a/toys/pending/init.c b/toys/pending/init.c index b147911f..afc9a3ed 100644 --- a/toys/pending/init.c +++ b/toys/pending/init.c @@ -308,11 +308,7 @@ static void waitforpid(pid_t pid) { if (pid <= 0) return; - for(;;) { - pid_t y = wait(NULL); - mark_as_terminated_process(y); - if (kill(y, 0)) break; - } + while (!kill(pid, 0)) mark_as_terminated_process(wait(NULL)); } static void run_action_from_list(int action) -- cgit v1.2.3