From: Jeff King <peff@peff•net>
To: Andrew Au <cshung@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v2] transport-helper, connect: add atexit handler to reap children on abnormal exit
Date: Wed, 11 Mar 2026 14:42:06 -0400 [thread overview]
Message-ID: <20260311184206.GA1911377@coredump.intra.peff.net> (raw)
In-Reply-To: <20260311142021.3464789-1-cshung@gmail.com>
On Wed, Mar 11, 2026 at 02:20:21PM +0000, Andrew Au wrote:
> +/*
> + * Ensure the connection child (ssh, proxy, or local git) is reaped on
> + * any exit path, mirroring the transport-helper.c atexit pattern.
> + */
> +static struct child_process *conn_to_reap;
> +
> +static void cleanup_conn_on_exit(void)
> +{
> + if (conn_to_reap)
> + finish_command(conn_to_reap);
> +}
This waits for the command to exit. Are we sure it will always do so,
and it won't sometimes be waiting on us to do something (like close a
pipe that is feeding it)? If not, then we can get deadlocks.
I think you actually want to kill(), then wait. There is already support
for this in run-command.[ch]. You just need to set the clean_on_exit
flag of the child_process struct.
I actually wonder if clean_on_exit should become the default behavior.
It should be rare for our subprocesses to outlive us. Commit afe19ff7b5
(run-command: optionally kill children on exit, 2012-01-07) mentions the
pager, but I don't think that was true even back then (we wait around
for the pager to finish). There are a few cases where we spawn daemon
programs, which would need to be marked as survivable. I think mostly we
have not looked into it because somebody would have to look at each
run_command() callsite.
Anyway, that is a bit of a tangent. I think it would be safe to mark the
spots in this patch as clean_on_exit.
-Peff
next prev parent reply other threads:[~2026-03-11 18:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 16:51 [PATCH 0/1] Fix zombie children when git is PID 1 in containers Andrew Au
2026-02-23 16:51 ` [PATCH 1/1] transport-helper, connect: add atexit handler to reap children on abnormal exit Andrew Au
2026-02-23 17:14 ` Kristoffer Haugsbakk
2026-02-23 18:12 ` Andrew Au
2026-03-11 14:20 ` [PATCH v2] " Andrew Au
2026-03-11 17:58 ` Junio C Hamano
2026-03-11 18:19 ` Andrew Au
2026-03-11 19:38 ` Junio C Hamano
2026-03-11 18:42 ` Jeff King [this message]
2026-03-12 19:55 ` [PATCH v3] transport-helper, connect: use clean_on_exit " Andrew Au
2026-03-12 20:40 ` Jeff King
2026-03-12 20:41 ` Jeff King
2026-03-12 20:49 ` Junio C Hamano
2026-03-12 21:49 ` [PATCH v4] " Andrew Au
2026-03-12 22:04 ` Junio C Hamano
2026-03-14 16:08 ` Jeff King
2026-03-14 17:24 ` Junio C Hamano
2026-03-16 20:31 ` Junio C Hamano
2026-03-16 21:19 ` Jeff King
2026-03-16 21:24 ` Junio C Hamano
2026-03-11 21:15 ` [PATCH 0/1] Fix zombie children when git is PID 1 in containers brian m. carlson
2026-03-12 19:40 ` Andrew Au
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=20260311184206.GA1911377@coredump.intra.peff.net \
--to=peff@peff$(echo .)net \
--cc=cshung@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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