You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Breaking change] Make Process.Run* kill the entire process tree on timeout or cancellation #136466
The .NET 11 System.Diagnostics.Process.Run* convenience methods kill only the immediate child process on timeout or cancellation. Descendants started by that child can remain running.
This matters when launching shells, scripts, build tools, or other programs that spawn subprocesses. Timing out or canceling the operation can leave work running in the background, consuming resources or holding files and redirected standard-stream handles open.
For example, if the launched process starts a long-running child, timing out Process.RunAndCaptureText(...) can terminate the launched process without terminating that child.
The helpers do not provide a way to request whole-process-tree cleanup. Callers needing it must abandon the convenience methods and manually combine Process.Start, output capture, timeout accounting, exit waiting, and Kill(entireProcessTree: true).
The current capture implementation uses parameterless process.Kill() on capture failure and delegates post-capture timeouts to a single-process handle wait: synchronous implementation, asynchronous implementation.
Proposed change
Make all Process.Run* methods always kill the entire launched process tree on timeout or cancellation, rather than only the immediate child:
Process.Run (all overloads)
Process.RunAsync (all overloads)
Process.RunAndCaptureText (all overloads)
Process.RunAndCaptureTextAsync (all overloads)
Apply this consistently whether timeout/cancellation occurs during output capture or while waiting for process termination. Preserve the existing timeout/cancellation reporting semantics and normal-completion behavior.
This should be the default behavior, without requiring another opt-in flag.
Breaking-change impact
This is an intentional behavioral breaking change: descendants that previously survived a timeout or cancellation would now be terminated.
Callers that intentionally need descendants to survive should use the lower-level Process.Start APIs and manage their lifecycle explicitly.
Note from human: both Run and RunAsync use only SafeProcessHandle, which lacks the Kill(entireProcessTree: true) overload. It would be nice to have the best of both words: keep using SPH but also extend it.
changed the title [-][Breaking change proposal] Make Process.Run* kill the entire process tree on timeout or cancellation[/-][+][Breaking change] Make Process.Run* kill the entire process tree on timeout or cancellation[/+]on Oct 27, 2026
Activity
dotnet-policy-service commentedon Oct 26, 2026
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
adamsitnik commentedon Oct 26, 2026
Note from human: both Run and RunAsync use only SafeProcessHandle, which lacks the
Kill(entireProcessTree: true)overload. It would be nice to have the best of both words: keep using SPH but also extend it.[-][Breaking change proposal] Make Process.Run* kill the entire process tree on timeout or cancellation[/-][+][Breaking change] Make Process.Run* kill the entire process tree on timeout or cancellation[/+]