Skip to content

Tree kill: split the PIDs across taskkill calls, and kill a taskkill that hangs - #64

Merged
HalRiveria-Bot merged 1 commit into
mainfrom
fix/tree-kill-limits
Nov 17, 2026
Merged

HalRiveria-Bot merged 1 commit into
mainfrom
fix/tree-kill-limits

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

Two rare failures in Stop-PkProcessTree, the tree kill behind timeouts, aborts and the dispatcher's force-stop:

  • Too many programs for one command line. Every PID went on one taskkill /T command line. That passes Windows' 32,767-character limit at roughly 2,500-3,000 programs (probed: a 36,449-character line fails with "The filename or extension is too long"), and the dispatcher's force-stop passes every running job at once. taskkill then couldn't start, so the fallback killed only the listed programs, and their children ran on until PowerShell exited.
  • A taskkill that hangs was left running. After its 10-second wait it was abandoned, still running and outside the Job Object.

What changed

  • The PIDs now go to as many taskkill calls as the command-line limit needs (Split-PkTaskkillArguments), each still with /T.
  • A taskkill still running after its wait is killed before the fallback kills the programs directly.
  • The body moved to a private Stop-PkProcessTreeCore. Its extra parameters (the taskkill path, its wait, the argument limit) exist so the harness can drive both cases without starting thousands of programs. Stop-PkProcessTree's parameters and result are unchanged.
  • README and help no longer say "one taskkill call".

Testing

  • New harness section AV:
    • 3,000 PIDs split into 2 argument lists under the real limit, each PID exactly once.
    • Five programs with a 30-character limit go to 3 calls of a stand-in taskkill (a small compiled program that logs its arguments), each under the limit.
    • A stand-in that hangs is killed after a 500 ms wait, and the programs are still killed.
    • With the real taskkill and one PID per call, every program's children are still killed.
  • The splitting, many-calls and hung-taskkill checks failed on the code before the fix (no splitter; 1 call of 60 characters; the stand-in left running) and pass now.
  • Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (526 assertions each).

🤖 Generated with Claude Code

…that hangs

Stop-PkProcessTree put every PID on one taskkill command line, which
passes Windows' 32,767-character limit at roughly 2,500-3,000 programs
(the dispatcher's force-stop passes every running job at once). taskkill
then couldn't start, and the fallback killed only the listed programs, not
their children. The PIDs now go to as many taskkill calls as the limit
needs.

A taskkill still running after its 10-second wait was left running,
outside the Job Object. It's now killed before the fallback runs.

The body moves to Stop-PkProcessTreeCore, whose extra parameters (a
stand-in taskkill, a shorter wait and argument limit) let the harness
drive both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 5d5fc1a into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/tree-kill-limits branch November 17, 2026 22:36
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.

2 participants