public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] daemon: handle EINTR failures from waitpid()
@ 2025-06-30  4:13 Carlo Marcelo Arenas Belón
  2025-06-30  9:00 ` Phillip Wood
  0 siblings, 1 reply; 3+ messages in thread
From: Carlo Marcelo Arenas Belón @ 2025-06-30  4:13 UTC (permalink / raw)
  To: git
  Cc: Stephen R . van den Berg, Erik Faye-Lund,
	Carlo Marcelo Arenas Belón

Since 695605b508 (git-daemon: Simplify dead-children reaping logic,
2008-08-14), the logic to check for zombie children was moved out of
the SIGCHLD signal handler, but adding checks for a failed waitpid()
were missed, with the possibility that a badly timed signal could
prevent the promptly reaping of those defunct processes.

After the refactoring of 30e1560230 (daemon: use run-command api for
async serving, 2010-11-04), that reproduced that bug, a single
process could be skipped from reaping, so prevent that by adding the
missing error handling, and while at it make sure that ECHILD (or
other errors) are correctly reported as a BUG().

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 daemon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/daemon.c b/daemon.c
index d1be61fd57..16ae66a2da 100644
--- a/daemon.c
+++ b/daemon.c
@@ -864,8 +864,11 @@ static void check_dead_children(void)
 			live_children--;
 			child_process_clear(&blanket->cld);
 			free(blanket);
-		} else
+		} else if (!pid)
 			cradle = &blanket->next;
+		else if (errno != EINTR)
+			BUG("invalid child '%" PRIuMAX "'",
+			    (uintmax_t)blanket->cld.pid);
 }
 
 static struct strvec cld_argv = STRVEC_INIT;
-- 
2.50.0.132.g32f443f09a.dirty


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-30 12:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  4:13 [PATCH] daemon: handle EINTR failures from waitpid() Carlo Marcelo Arenas Belón
2025-06-30  9:00 ` Phillip Wood
2025-06-30 12:18   ` Carlo Marcelo Arenas Belón

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox