diff options
author | Elliott Hughes <enh@google.com> | 2021-03-17 11:27:00 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2021-03-17 20:44:57 -0500 |
commit | 1cc17b2f2fe93fdf71ffb650c6013b7560dd2d2f (patch) | |
tree | e54bc72d34d6b7be2615e1f6123939498591c19f /toys/pending | |
parent | 620eeaf2fca0ebeb1179ffdc9bdf5d923691558c (diff) | |
download | toybox-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.c | 6 |
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) |