localenv: reap uv subprocesses on SIGINT/SIGTERM instead of orphaning them - #6107
Open
rugpanov wants to merge 1 commit into
Open
localenv: reap uv subprocesses on SIGINT/SIGTERM instead of orphaning them#6107rugpanov wants to merge 1 commit into
rugpanov wants to merge 1 commit into
Conversation
… them The CLI root never installs a signal handler, so a SIGTERM to just the CLI PID (supervisor, CI timeout, or VS Code stopping the child) did not cancel the command context. Even once cancelled, exec.CommandContext only SIGKILLs the direct child, leaving uv's own subprocesses (Python, build backends) running as orphans over a half-written .venv with held locks. Fix, scoped to the hidden `environments setup-local` command: - Install signal.NotifyContext(SIGINT, SIGTERM) in the command's RunE so signals cancel the pipeline context, mirroring experimental/genie. - Add an opt-in process.WithProcessGroup() execOption. On Unix it puts the child in its own process group (Setpgid) and, on cancellation, sends SIGTERM to the whole group so grandchildren are reaped, then relies on WaitDelay to escalate to SIGKILL if the leader hangs. On non-Unix it sets WaitDelay only (whole-tree kill needs a Job Object, out of scope). - Apply the option to the uv spawns in libs/localenv (version probe, python install / sync / pip seed, venv validation, and the installer pipeline). Default Background/Forwarded behavior for all other callers is unchanged. DECO-27811 Co-authored-by: Isaac
Contributor
Approval status: pending
|
Collaborator
Integration test reportCommit: 14aa98f
8 interesting tests: 4 RECOVERED, 4 SKIP
Top 3 slowest tests (at least 2 minutes):
|
rclarey
approved these changes
Jul 31, 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.
Changes
Scoped to the (still hidden)
environments setup-localcommand:signal.NotifyContext(SIGINT, SIGTERM)in the command'sRunEso signals cancel the pipeline context (mirrorsexperimental/genie). The CLI root does not install a signal handler.process.WithProcessGroup()option. On Unix it runs the child in its own process group (Setpgid) and, on cancellation, sendsSIGTERMto the whole group so grandchildren are reaped, withWaitDelayescalating toSIGKILLif the leader hangs. On non-Unix it setsWaitDelayonly (whole-tree kill would need a Job Object; out of scope).uvspawns inlibs/localenv(version probe, python install / sync / pip seed, venv validation, installer pipeline).Default
Background/Forwardedbehavior for all other subprocess callers is unchanged.Why
Previously a
SIGTERMto just the CLI PID (a supervisor, CI timeout, or VS Code stopping the child) never cancelled the command context, and even when cancelledexec.CommandContextonlySIGKILLs the direct child.uv sync's own subprocesses (Python, build backends) were left running as orphans over a half-written.venvwith held locks. DECO-27811.Tests
libs/processspawns a shell that backgrounds asleepgrandchild, cancels the context, and assertsBackgroundreturns within the grace period and the grandchild is reaped (kill(pid, 0)→ESRCH).go test ./libs/process/... ./libs/localenv/... ./cmd/environments/...and thelocalenv/helpacceptance suites pass;golangci-lintanddeadcodeclean; builds green fordarwinandwindows.This PR was written by Claude Code.