Skip to content

fix: kill the whole process group when a git clone's context is cancelled#3

Merged
alecthomas merged 2 commits into
block:mainfrom
luispadron:luis/git-fetch-process-group-kill
Jul 20, 2026
Merged

fix: kill the whole process group when a git clone's context is cancelled#3
alecthomas merged 2 commits into
block:mainfrom
luispadron:luis/git-fetch-process-group-kill

Conversation

@luispadron

Copy link
Copy Markdown
Contributor

exec.CommandContext only signals the direct child on context cancellation. git clone routinely has grandchildren (git-remote-https, or a real git spawned by a wrapper script), which survive the kill and keep the CombinedOutput pipe open — so Git.Fetch blocks until they exit on their own. We observed this adding 13 minutes to a timed-out clone of a large repo in Blox (a git wrapper was killed at the deadline while the underlying clone kept running).

This runs the clone in its own process group, kills the group on cancel, and sets a WaitDelay as a backstop. Unix-only via build tags; other platforms keep the default cancel behaviour plus the WaitDelay.

Also pins the test repos to an explicit initial branch so the suite passes on machines with init.defaultBranch=main.

luispadron and others added 2 commits July 20, 2026 17:38
…lled

exec.CommandContext only signals the direct child on cancellation.
git clone's grandchildren (git-remote-https, wrapper-spawned git)
survive the kill and hold the CombinedOutput pipe open, so Fetch
blocks until they exit on their own — observed adding 13 minutes to
a timed-out clone. Run the clone in its own process group, kill the
group on cancel, and bound Wait with a WaitDelay.

Co-authored-by: Claude Code <noreply@anthropic.com>
Ai-assisted: true
TestGitFetchWithRef assumes the default branch is master, failing on
machines with init.defaultBranch=main.

Co-authored-by: Claude Code <noreply@anthropic.com>
Ai-assisted: true
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@luispadron
luispadron marked this pull request as ready for review July 20, 2026 21:47
@luispadron
luispadron requested a review from alecthomas as a code owner July 20, 2026 21:47
@alecthomas
alecthomas merged commit f1611b1 into block:main Jul 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants