From 4b418105a73181eb59d2b83c6e788eaafd0e7caa Mon Sep 17 00:00:00 2001 From: Adrian Muzyka Date: Thu, 4 Jul 2024 10:21:04 +0000 Subject: [PATCH] sigchld_handler_service: Iterate over all service children If more than one service child is killed, the SIGCHLD signals can be coalesced, causing service to miss worker exit and perform clean-up --- memcr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/memcr.c b/memcr.c index 08c5c84..5fbc6b8 100644 --- a/memcr.c +++ b/memcr.c @@ -915,7 +915,7 @@ static void clear_pid_on_worker_exit_non_blocking(pid_t worker) { for (int i=0; isi_pid == waitpid(sip->si_pid, &status, WNOHANG)) { - fprintf(stdout, "[+] Worker %d exit.\n", sip->si_pid); - clear_pid_on_worker_exit_non_blocking(sip->si_pid); + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { + clear_pid_on_worker_exit_non_blocking(pid); } + errno = _errno; }