Repository navigation
Count a tree kill as done when taskkill reports a partial failure - #41
Merged
Merged
Conversation
taskkill /T exits non-zero if any process in the tree couldn't be killed, even when it killed the program itself. For a single program, Stop-PkProcessTree then returned $false, so a job killed for its time limit could show TimedOut = $false. It happened most often with `cmd /c`: taskkill kills the children first, cmd ends on its own as soon as its child dies, and taskkill then finds it already gone. It also happens when a child can't be killed. The "any listed process is now gone" check, which already covered several programs, now covers one too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
What was wrong
taskkill /Texits non-zero if any process in the tree couldn't be killed, even when it killed the program itself. With one program,Stop-PkProcessTreetook that at face value and returned$false, so a job killed for its time limit could come back withTimedOut = $false.The most common trigger is a
cmd /cwrapper. Taskkill kills the children first,cmdends on its own as soon as its child dies, and taskkill then reports it as "no running instance". The harness's existing batch-timeout test hit this intermittently: onmainit failed 4 times in 8 on Windows PowerShell 5.1 and 2 in 8 on PowerShell 7. A child that refuses termination triggers it every time.What changed
Stop-PkProcessTreealready counted a partial taskkill failure as a kill when one of several listed processes was gone afterwards. It now does the same for a single program. A program that happened to exit on its own in the instant before taskkill also counts as killed. Of the kit's callers, only the time limit reads the result, and it only kills a program that's already past its limit.How it was tested
New harness section AJ makes a
cmd /c pingtree's ping child refusePROCESS_TERMINATE, through its DACL, and then checks two things:Stop-PkProcessTreereturns$truefor the killed parent.TimedOut = $true.Both failed before the fix on 5.1 and 7. If taskkill runs elevated, it may ignore the DACL. The checks still hold then, but they don't exercise the failure path, and the test message says so. Separately, the batch-timeout case run 15 times now sets
TimedOutevery time on both runtimes. The harness passes on 5.1 and 7 (438 assertions each).🤖 Generated with Claude Code