Repository navigation
Keep a killed program's tree job until it's completed, so -KillTreeOnExit doesn't warn after the kit's own kill - #122
Merged
Conversation
…ograms a list is quoted for
The dispatcher checks for an abort once per pass, and its start loop read only the token, which that check cancels. So a Ctrl+C landing while the loop was starting programs, or a -JobStarter that requested an abort, still filled every free slot on that pass. The start loop now also reads the abort flag before each job, ahead of the shared budget's Wait(0) so no slot is taken for a job that won't start. Harness section O covers a -JobStarter that requests an abort, with a plain limit and with a shared budget.
The test that kills a live tree listed beside a disposed process counted leftover pings right after Stop-PkProcessTree returned. Ending a Job Object returns before Windows has finished tearing its processes down, so on a CI runner the ping was still listed once. It now waits up to 5 seconds for it to go, as the other kill tests do.
…Exit doesn't warn after the kit's own kill With -KillTreeOnExit, a program the kit killed (for its time limit, Invoke-PkProcessWithTimeout's limit, or an abort's force-stop) got the warning that it "has no Job Object of its own". KillTree closed the program's tree job once it had ended it, so -KillTreeOnExit, ending it again once the program had exited, found no tree job. KillTree now leaves the tree job open: a second KillTree ends an empty job and succeeds, quietly. Complete-PkProcess closes it as before, and so do the force-stop and Invoke-PkProcessWithTimeout's cleanup, which dispose a killed program without completing it. Harness section BJ covers the three kills; BF's check that a kill releases the tree job now expects the release at Complete-PkProcess, and a second KillTree to succeed. The README's Limits also says a program whose path is over 260 characters can't be started: Windows refuses it, long paths enabled or not.
… every dispatcher kill test On CI, 'a -JobFinalize that throws gets no -JobAbortCleanup for its finished job' failed under Windows PowerShell 5.1 with 1 ping left: it counted leftover pings right after the dispatcher's teardown kill, and ending a Job Object returns before Windows has torn its processes down. Five other tests count the same way. They now all use one helper, Get-LimitPingLeft, which waits up to 5 seconds for the pings to go, and still fails one that survives.
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: with
-KillTreeOnExit, a program the kit killed got the warning "-KillTreeOnExit can't stop what process N left running: the program has no Job Object of its own ...". That covered a kill for the dispatcher's or batch's time limit, forInvoke-PkProcessWithTimeout's limit, and in an abort's force-stop. The kill goes throughKillTree, which closed the program's tree job once it had ended it. So when-KillTreeOnExitthen ended the exited program's tree,Stop-PkExitedJobTreefound no tree job and took the no-tree branch. Nothing was left running; only the warning was wrong. This has been there since 4.2.What changed:
KillTreeno longer closes the tree job. A secondKillTreeends an empty job, which succeeds, soStop-PkExitedJobTreestays quiet.Complete-PkProcessstill closes the tree job.Stop-PkJobProcess) andInvoke-PkProcessWithTimeout's cleanup now close it themselves, since they dispose a killed program without completing it.-JobFinalizethat doesn't callComplete-PkProcess, or a directStop-PkProcessTree) keeps its tree job until garbage collection, as an unkilled one already did.TypesVersionin End what a program left running when its start is rolled back after it exited #115, so it doesn't change again.Also in this PR: a line in the README's Limits. A program whose path is longer than 260 characters can't be started, even with long paths enabled and in the
\\?\form. Windows refuses it with "The filename or extension is too long" (or, for a plain path on PowerShell 7, "The system cannot find the file specified"). I checked this with a 369-character path on Windows PowerShell 5.1 and PowerShell 7.Also: a harness timing fix. This PR's first CI run failed one assertion under Windows PowerShell 5.1: "a -JobFinalize that throws gets no -JobAbortCleanup for its finished job, only for the killed one (... 1 left ...)". It counted leftover pings right after the dispatcher's teardown kill, and ending a Job Object returns before Windows has torn its processes down. That's the same pattern #120 fixed in one test. Five other tests counted the same way, so all six now use one helper,
Get-LimitPingLeft, which waits up to 5 seconds for the pings to go and still fails one that survives.How it was tested: harness section BJ runs each of the three kills with
-KillTreeOnExitand checks the ping is gone with no warning. Section BF's check thatStop-PkProcessTreelets go of the tree job now expects the tree job to stay after the kill, a secondKillTreeto succeed, and the release atComplete-PkProcess.Before the fix (Windows PowerShell 5.1 and PowerShell 7, the same on both):
After: all three pass with 0 warnings, and so does the updated BF check.
Build/Update-ParallelKitCSharp.ps1 -Compilebuilds the C# with no warnings under bothcsc.exe(C# 5) and the .NET SDK (LangVersion5).Full harness: all 779 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.