Repository navigation
Warn when killing a program with no Job Object of its own may leave something running - #134
Merged
Merged
Conversation
…something running
…d say what a kill without a tree job can miss
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
Some programs have no Job Object of their own: Windows refused one at the start, or the kit runs in
NoJobmode. Killing one of them for its time limit, or in an abort's force-stop, goes totaskkill /T, which misses a child whose parent has already exited. The kill still counted as complete, with no warning.Stop-PkProgramTreereturnedKilledwhen there was no tree job to check.#133 added a warning only for a program whose Job Object Windows won't end. The README only mentioned the missed child for that case too.
What changed
Invoke-PkProcessWithTimeout's time limit. The warning names the process and why it was killed.-KillTreeOnExit's once-per-session check for a program with no Job Object of its own, so only one of the two warnings shows.Invoke-PkProcessWithTimeout's cleanup doesn't warn a second time, since its error already says the program may still be running.-KillTreeOnExitparagraph says its warnings don't repeat once a kill has warned about the same cause.No C# change.
How it was tested
Seven new assertions:
pingthrough a.cmdfile and exits at once. The tree is killed through the dispatcher's time limit, an abort's force-stop andInvoke-PkProcessWithTimeout's time limit. Each kill runs withTestNoTreeJoband withTestRefuseTreeJob. Each case expects the ping to be left running and exactly one warning saying the program has no Job Object of its own.TestNoTreeJob.Before the fix (main's kit with the new harness), on Windows PowerShell 5.1 and PowerShell 7 alike:
After: the full harness passes on Windows PowerShell 5.1 and PowerShell 7 (819 assertions each).