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
Use TerminateJobObject for Process.Kill(entireProcessTree: true) on Windows #126273
As soon as #126107 is done, we are going to implement #13943 which is going to force us to use STARTUPINFOEX on Windows. This is then going to let us implement #101985 which will require using Job objects on Windows. This particular job will have to use JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, but I believe that we should go one step further and always create a new job when starting new Process with CreateProcess on Windows.
Then for processes started without UseShellExecute, Process.Kill(entireProcessTree: true) becomes a single sys-call invocation. It's not just way faster but simply way more reliable than current approach.
An experiment that I've run for #123865 (comment) shows 44x wall clock time improvement and 4879x less allocated memory when dealing only with process tree that contained 3 child processes.
we should go one step further and always create a new job when starting new Process with CreateProcess on Windows.
This would be an observable behavior change. It is not unusual for programs to special case behavior when running inside a job. IsProcessInJob Windows API encourages that. I think this should be an opt-in behavior.
Process.Kill(entireProcessTree: true) becomes a single sys-call invocation. It's not just way faster but simply way more reliable than current approach.
The job tree is not the same as the process tree. Again, observable behavior change.
Activity
dotnet-policy-service commentedon Mar 29, 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 Mar 29, 2026
cc @Youssef1313
jkotas commentedon Mar 29, 2026
This would be an observable behavior change. It is not unusual for programs to special case behavior when running inside a job.
IsProcessInJobWindows API encourages that. I think this should be an opt-in behavior.The job tree is not the same as the process tree. Again, observable behavior change.
adamsitnik commentedon Jun 29, 2026
Closing as not planned for the reasons described by @jkotas