Skip to content

Use TerminateJobObject for Process.Kill(entireProcessTree: true) on Windows #126273

@adamsitnik

Description

@adamsitnik

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions