fix: kill the whole process group when a git clone's context is cancelled#3
Merged
alecthomas merged 2 commits intoJul 20, 2026
Merged
Conversation
…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
|
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:
For more information about GitHub Code Scanning, check out the documentation. |
luispadron
marked this pull request as ready for review
July 20, 2026 21:47
alecthomas
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
exec.CommandContextonly signals the direct child on context cancellation.git cloneroutinely has grandchildren (git-remote-https, or a real git spawned by a wrapper script), which survive the kill and keep theCombinedOutputpipe open — soGit.Fetchblocks 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
WaitDelayas a backstop. Unix-only via build tags; other platforms keep the default cancel behaviour plus theWaitDelay.Also pins the test repos to an explicit initial branch so the suite passes on machines with
init.defaultBranch=main.