Repository navigation
End what a program left running when its start is rolled back after it exited - #115
Merged
Merged
Conversation
HalRiveria
force-pushed
the
fix/rollback-exited-program
branch
from
December 3, 2026 00:29
d18f630 to
69ed874
Compare
…t exited When a program's output reader couldn't start, the rollback stopped the program with Stop-PkProcessTree, which passes over a program that has already exited, so a child it left running was never stopped. The dispatcher's cleanup when a -JobStarter throws after starting a program had the same gap. Both now kill the program's tree job first, which reaches its children whether or not it is still running, and fall back to Stop-PkProcessTree only when it has none. The rollback now also releases the tree job's handle and disposes the process, as the dispatcher's cleanup already disposed it. A test hook, PkStreamReadTask.TestFailRunDelayMs, holds the failing reader start so the program has exited by then; TypesVersion is 16. Harness section AW covers the rollback on both start paths and the dispatcher's cleanup.
HalRiveria
force-pushed
the
fix/rollback-exited-program
branch
from
December 3, 2026 00:42
69ed874 to
a6a8d7c
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 #114, merge after it.
What was wrong: two places stop a program whose start has failed:
Start-PkProcesswhen one of its output readers can't start (Stop a program whose output readers can't start, and warn when -KillTreeOnExit can't reach a program's tree #111);-JobStarterthrows after starting its program.Both used
Stop-PkProcessTree, which passes over a program that has already exited. If the program had exited by then, a child it left running (cmd /c start /b ...) was never stopped. It stayed in the kit's Job Object, so it ended with PowerShell at the latest. The rollback also left the program's process handle and its tree job's handle for the garbage collector.What changed:
[PkChildProcessJob]::KillTree), which reaches its children whether or not the program is still running. They fall back toStop-PkProcessTreeonly when that fails (no tree job, as withStartMode NoJob).PkStreamReadTask.TestFailRunDelayMs, holds the failing reader start, so the program has exited by the time the rollback runs. Because that changes the C#,TypesVersionis now 16: a session that loaded an older copy has to be restarted.How it was tested: harness section AW starts
cmd /d /c start "" /b ping ...and makes its stderr reader fail after cmd.exe has exited, on both start paths, then checks the ping isn't left running. It also runs the dispatcher with a-JobStarterthat waits for the same program to exit and then throws.Before the fix (Windows PowerShell 5.1 and PowerShell 7, the same on both):
After: all three pass with 0 left running.
Build/Update-ParallelKitCSharp.ps1 -Compilebuilds the C# with no warnings under bothcsc.exe(C# 5) and the .NET SDK (LangVersion5).Full harness: all 758 assertions pass on Windows PowerShell 5.1 and on PowerShell 7.