Skip to content

fix(shell): Windows commands run in a Job Object that bounds and terminates their process tree - #425

Merged
PHPCraftdream merged 5 commits into
mainfrom
fix/job-object-hotfix-20261115
Nov 15, 2026
Merged

PHPCraftdream merged 5 commits into
mainfrom
fix/job-object-hotfix-20261115

Conversation

@PHPCraftdream

Copy link
Copy Markdown
Owner

Windows: every command runs in a Job Object (#151)

The hang (a self-recursive PATH shim whose exec git "$@" resolved to itself) left orphan chains that taskkill /T cannot reach: the parent bash waited for pipe EOF for 90 minutes.

  • The Windows exec handler now puts each command into a Job Object: active-process limit 2048 (shexec.SetMaxProcessesPerCommand), no KILL_ON_JOB_CLOSE (a deliberate daemon survives a normal exit), TerminateJobObject on cancel and Stop with taskkill /T as the fallback.
  • Regression tests: T1 (self-recursive shim chain, fails in 13.8 s without the Job Object), T2 (cancel kills orphaned descendants), T3 (deliberate daemon survives normal exit), T4 (retained Stop kills orphaned descendants), plus shexec job tests. The first versions of T1/T2/T4 were wrong as tests (no shebang, output redirected away from the pipe, path-converted marker), not as code; the fix and the test fixes are in the three commits.

Full fork CI run 43747015956 on 8193129cc is green (22 jobs).

🤖 Generated with Claude Code

PHPCraftdream and others added 5 commits November 15, 2026 18:18
…inates their process tree

A diagnostic git shim whose last line was exec git "$@" re-executed itself through PATH
forever; Cygwin exec leaves orphans, so taskkill /T could not reach the chain and the
parent bash waited for pipe EOF for 90 minutes. Every external command now gets a Job
Object with an active-process limit (no kill-on-close, daemons still survive a normal
exit); cancel and stop call TerminateJobObject first and fall back to taskkill /T.
Regression tests: self-recursive PATH shim is bounded, cancel and Stop kill orphaned
descendants, a deliberate daemon survives a normal exit, job helper unit tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Keeps the shell directory at its recorded file count.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…chain, killByPID waits for exit

The first versions of T1, T2 and T4 passed or failed for test-design reasons
(sleeper redirected away from the pipe, shim without shebang, marker rewritten
by MSYS path conversion). The sleeper now holds the output pipe so Run blocks
until cancel and TerminateJobObject is what ends the chain. No production
change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…n guard)

noctx forbids exec.Command and TestNoUnhardenedProcessSpawns forbids
exec.CommandContext: platform.Command satisfies both and keeps the console
window hidden.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@PHPCraftdream
PHPCraftdream merged commit 9df018c into main Nov 15, 2026
1 check passed
@PHPCraftdream
PHPCraftdream deleted the fix/job-object-hotfix-20261115 branch November 15, 2026 19:32
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.

1 participant