aboutsummaryrefslogtreecommitdiff
path: root/toys/pending
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-03-17 11:27:00 -0700
committerRob Landley <rob@landley.net>2021-03-17 20:44:57 -0500
commit1cc17b2f2fe93fdf71ffb650c6013b7560dd2d2f (patch)
treee54bc72d34d6b7be2615e1f6123939498591c19f /toys/pending
parent620eeaf2fca0ebeb1179ffdc9bdf5d923691558c (diff)
downloadtoybox-1cc17b2f2fe93fdf71ffb650c6013b7560dd2d2f.tar.gz
init: fix waitforpid().
The kill(2) should be checking whether `pid` still exists, not the process that wait(2) just told us has exited.
Diffstat (limited to 'toys/pending')
-rw-r--r--toys/pending/init.c6
1 files changed, 1 insertions, 5 deletions
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)