]> git.ipfire.org Git - thirdparty/git.git/commit
transport-helper, connect: use clean_on_exit to reap children on abnormal exit
authorAndrew Au <cshung@gmail.com>
Thu, 12 Mar 2026 21:49:37 +0000 (21:49 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Mar 2026 21:51:50 +0000 (14:51 -0700)
commitdd3693eb0859274d62feac8047e1d486b3beaf31
treefa627c35b351b91032f0e760d5add5808db01ae4
parent7f19e4e1b6a3ad259e2ed66033e01e03b8b74c5e
transport-helper, connect: use clean_on_exit to reap children on abnormal exit

When a long-running service (e.g., a source indexer) runs as PID 1
inside a container and repeatedly spawns git, git may in turn spawn
child processes such as git-remote-https or ssh. If git exits abnormally
(e.g., via exit(128) on a transport error), the normal cleanup paths
(disconnect_helper, finish_connect) are bypassed, and these children are
never waited on. The children are reparented to PID 1, which does not
reap them, so they accumulate as zombies over time.

Set clean_on_exit and wait_after_clean on child_process structs in both
transport-helper.c and connect.c so that the existing run-command
cleanup infrastructure handles reaping on any exit path. This avoids
rolling custom atexit handlers that call finish_command(), which could
deadlock if the child is blocked waiting for the parent to close a pipe.

The clean_on_exit mechanism sends SIGTERM first, then waits, ensuring
the child terminates promptly. It also handles signal-based exits, not
just atexit.

Signed-off-by: Andrew Au <cshung@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c
transport-helper.c