From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org
Cc: "Stephen R . van den Berg" <srb@cuci.nl>,
"Erik Faye-Lund" <kusmabite@gmail.com>,
"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH] daemon: handle EINTR failures from waitpid()
Date: Sun, 29 Jun 2025 21:13:03 -0700 [thread overview]
Message-ID: <20250630041303.93370-1-carenas@gmail.com> (raw)
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 reply other threads:[~2025-06-30 4:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 4:13 Carlo Marcelo Arenas Belón [this message]
2025-06-30 9:00 ` [PATCH] daemon: handle EINTR failures from waitpid() Phillip Wood
2025-06-30 12:18 ` Carlo Marcelo Arenas Belón
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250630041303.93370-1-carenas@gmail.com \
--to=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=kusmabite@gmail.com \
--cc=srb@cuci.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox