Repository navigation
Kill descendants in Process.Kill(entireProcessTree) polyfill - #657
Merged
Merged
Conversation
This was referenced Oct 12, 2026
This was referenced Oct 13, 2026
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.
Bug
The
Process.Kill(bool entireProcessTree)polyfill (net4x, netstandard, netcoreapp2.x, uap) ignored its argument and calledProcess.Kill(), soKill(entireProcessTree: true)left every child process running. It also threwInvalidOperationExceptionfor a process that had already exited, where the BCL returns.Fix
Kill(true)now goes through a nestedProcessTreeHelper:ps -A -o pid=,ppid=, then the root and each descendant are sent SIGKILL. A child started between the listing and the kill is missed, and ifpscannot be run only the root is killed. This is recorded as a//Note:in the API list.InvalidOperationException, and failures to terminate are collected into anAggregateException.The Unix path was not executed: I only had Windows available, and the repo's tests run on Windows CI.
Tests
Process_Kill_EntireProcessTree_KillsDescendantsstarts a shell (cmd /c ping -n 60on Windows,sh -cwithsleep 60elsewhere) whose child inherits the redirected output pipe, kills the tree, and asserts the output reaches its end within 20 seconds, which only happens once the child has exited too.Process_Kill_EntireProcessTree_Exitedkills the tree of an exited process.Both fail on net48 without the fix and pass on net48 and net10.0 (BCL). The whole
Process*test group passes on net48.