From bf920a533d3cc3006f2cbded2b368c828bac8cca Mon Sep 17 00:00:00 2001 From: Lester Hightower Date: Tue, 2 Jul 2024 10:14:50 -0400 Subject: [PATCH] Fixed waitpid handling --- adhocify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adhocify.c b/adhocify.c index 3047286..9e642c1 100644 --- a/adhocify.c +++ b/adhocify.c @@ -709,7 +709,7 @@ void child_handler(int signum, siginfo_t *info, void *context) while (1) { int status; pid_t p = waitpid(-1, &status, WNOHANG); - if(p == 0) // No more children to reap + if(p == 0 || (p == -1 && errno == ECHILD)) // No more children to reap { return; // exits infinite while loop and child_handler() function }