Repository navigation
Warn when -KillTreeOnExit can't end what an exited program left running - #116
Merged
Merged
Conversation
HalRiveria
force-pushed
the
fix/killtree-failure-warning
branch
2 times, most recently
from
December 3, 2026 00:42
c3d696c to
8b69970
Compare
Once a program exits, -KillTreeOnExit ends what it left running through the program's own Job Object, and discarded the result: if Windows wouldn't end that Job Object, the leftovers kept running with no sign, showing only as a stream timeout if they held the output. There is no fallback once the program is gone (taskkill /T finds children only through their parent), so it now warns, once per session, naming the process, like the warning for a program without a Job Object of its own. A test hook, PkChildProcessJob.TestFailTerminate, makes TerminateJobObject count as refused. Harness section BJ covers the batch, the dispatcher and Invoke-PkProcessWithTimeout, and that the warning shows once. The README's -KillTreeOnExit paragraph mentions it.
HalRiveria
force-pushed
the
fix/killtree-failure-warning
branch
from
December 3, 2026 00:53
8b69970 to
7325fae
Compare
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.
Depends on #115, merge after it.
What was wrong: once a program exits,
-KillTreeOnExitends what it left running by ending the program's own Job Object (Stop-PkExitedJobTree, through[PkChildProcessJob]::KillTree), and it threw the result away. If Windows refused to end that Job Object, nothing said so. Leftovers that held the program's output showed only asStreamTimedOut, and the others kept running unseen until they ended or PowerShell exited. They're still in the kit's own Job Object, so PowerShell exiting ends them. No cause for such a failure is known: the kit creates the Job Object with full access.What changed: there's no fallback once the program is gone (
taskkill /Tfinds children only through their parent), so the kit now warns, once per session, naming the process. It works like the existing warning for a program without a Job Object of its own: aClaimKillTreeWarningin the C#, re-armed byTestResetJobWarnings. The README's-KillTreeOnExitparagraph mentions it.A harness-only hook,
PkChildProcessJob.TestFailTerminate, makesKillTree'sTerminateJobObjectcount as refused. This changes the C#; theTypesVersionbump is in #115, which this stacks on.How it was tested: harness section BJ runs a program that exits while a child it started holds its output, with the hook on. It does this through the batch, the dispatcher and
Invoke-PkProcessWithTimeout, and checks that the child is left running with exactly one warning. A second program after that gets no second warning.Before the change (Windows PowerShell 5.1 and PowerShell 7, the same on both):
After: all pass, each with one message:
[WARNING] -KillTreeOnExit couldn't stop what process N left running: Windows wouldn't end the program's own Job Object, so anything it started may still be running. It still ends when PowerShell does. Shown once.Build/Update-ParallelKitCSharp.ps1 -Compilebuilds the C# with no warnings under bothcsc.exe(C# 5) and the .NET SDK (LangVersion5).Full harness: all 766 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.