git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] daemon: handle EINTR failures from waitpid()

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Jun 30, 2025, 04:13 UTC
Message-ID
<20250630041303.93370-1-carenas@gmail.com>

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
Next: Phillip Wood
Message 1 of 3 in “daemon: handle EINTR failures from waitpid()”
  1. daemon: handle EINTR failures from waitpid()Carlo Marcelo Arenas Belón, Jun 30, 2025
  2. Phillip WoodJun 30, 2025
  3. Carlo Marcelo Arenas BelónJun 30, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.