sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Add support for killing a process group

Open sgjesse opened this issue 10 years ago • 8 comments

Right now one can only kill a single process using dart:io. Either through Process.kill on a Process instance or by using the static Process.killPID.

In some situations killing a process group is required.

Also see http://stackoverflow.com/questions/28497734/kill-process-group.

sgjesse avatar Feb 18 '15 07:02 sgjesse

Process groups are only present on Linux and OS X, so for Windows this cannot work.

This also require a way to get the process group of the process in question. This could be handled through the API, so that the API is passed the PID, but kills the GID of that PID.

On Windows there are Job Objects for grouping processes together. A Job Object is a separate kernel object which can have processes assigned.

sgjesse avatar Feb 18 '15 07:02 sgjesse

This comment was originally written by @zoechi


This might be close enough http://stackoverflow.com/a/1173376/217408

DartBot avatar Apr 23 '15 06:04 DartBot

Issue #23304 has been merged into this issue.


cc @iposva-google. cc @skabet. cc @sgjesse.

kevmoo avatar Apr 23 '15 07:04 kevmoo

Whether it explicitly has process trees or not, Windows still has the issue where killing a parent process won't kill its children, which makes it very hard to work with pub programmatically. Having some cross-platform way to say "kill this process and all its children", whatever that means under the hood on a given platform, is really important.

nex3 avatar Apr 23 '15 19:04 nex3

Please DOCUMENT THIS!

I just spent an hour trying to work out why Process.kill() doesn't do anything and it's not mentioned in the documentation for it at all.

Timmmm avatar Nov 15 '19 11:11 Timmmm

Um.. I can confirm this issue on Windows.

The workaround for Windows user is to obtain from tasklist in terminal, and kill the process by Process.killPid (or taskkill), but If there is a bunch of same name, there is no way to recognize which is the correct process to kill.

--

I'm not familiar with c++, but I found out a possible way to do It with Windows, hope It help somehow:

https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed https://docs.microsoft.com/zh-tw/windows/win32/api/jobapi2/nf-jobapi2-createjobobjectw?redirectedfrom=MSDN

Tokenyet avatar Feb 08 '20 12:02 Tokenyet

cc @brianquinlan for visibility

bkonyi avatar Jun 02 '23 19:06 bkonyi

I create a desktop server for laravel on flutter and i cannot terminate the server that start php artisan since using Process.kill method Does anyone have any solution at this date ?

Gilles-kpn avatar Jun 09 '25 07:06 Gilles-kpn