fix: Clean up orphaned Windows child processes on shutdown#11829
Merged
anthonyshew merged 4 commits intomainfrom Feb 13, 2026
Merged
fix: Clean up orphaned Windows child processes on shutdown#11829anthonyshew merged 4 commits intomainfrom
anthonyshew merged 4 commits intomainfrom
Conversation
…shutdown On Windows, killing a process does not cascade to its children. When using ConPTY (TUI mode), each PTY session spawns a conhost.exe process that was left orphaned after Ctrl+C because TerminateProcess only kills the direct child. This adds a per-child Job Object configured with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE so that when the job handle is dropped (after the child exits or is killed), all processes in the tree including conhost.exe and any grandchildren are terminated. Closes #11808
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Congrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
Contributor
Coverage Report
|
github-actions Bot
added a commit
that referenced
this pull request
Feb 13, 2026
## Release v2.8.8-canary.3 Versioned docs: https://v2-8-8-canary-3.turborepo.dev ### Changes - release(turborepo): 2.8.8-canary.2 (#11832) (`8adf1e1`) - fix: Harden token protection with `secrecy` crate and close exposure gaps (#11831) (`200e4c3`) - style: Fix oxfmt formatting in release workflow (#11833) (`d1f0b61`) - fix: Clean up orphaned Windows child processes on shutdown (#11829) (`93c5f10`) - docs: Replace mysql refs with postgres (#11827) (`c992107`) Co-authored-by: Turbobot <turbobot@vercel.com>
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.
Summary
conhost.exeprocesses remaining after Ctrl+C on Windows (reported in pnpm dev hangs in turborepo-basic with turbo ^2.8.7 (TUI opens, no tasks start) #11808)JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSEso the entire process tree is terminated when a child handle is droppedtest_process_tree_cleanupregression test that verifies grandchild processes are killed when the parent is stoppedContext
The primary issue from #11808 (ConPTY hanging due to
PSEUDOCONSOLE_INHERIT_CURSOR) was fixed in #11816. However, a follow-up report confirmed thatconhost.exeprocesses still remain orphaned after Ctrl+C on Windows.The root cause: on Unix,
setsid()creates a process group andkill(-pgid, SIGINT)kills the entire tree. On Windows, there was no equivalent —TerminateProcessonly kills the direct child, leavingconhost.exe(spawned by ConPTY) and any grandchild processes alive.How it works
Each spawned child process (both normal and PTY) is assigned to a Windows Job Object configured with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. When theChildHandleis dropped (after exit or kill), the job handle closes and Windows terminates all remaining processes in the job. This is the standard Windows mechanism for process tree management, analogous to Unix process groups.Job Object creation failures are logged but non-fatal — the child still runs, just without the cleanup guarantee.
Testing
The new
test_process_tree_cleanuptest:This test runs on both Unix (validating via
setsid+kill(-pgid)) and Windows (validating via Job Objects). It needs to pass on Windows CI to fully confirm the fix.