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(-)
From 7cee10b23b57f97ce78d8e50239112bc28456ae4 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Wed, 17 Mar 2021 11:27:00 -0700
Subject: [PATCH] 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(-)
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)
--
2.31.0.rc2.261.g7f71774620-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net