sdk
sdk copied to clipboard
Add support for killing a process group
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.
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.
This comment was originally written by @zoechi
This might be close enough http://stackoverflow.com/a/1173376/217408
Issue #23304 has been merged into this issue.
cc @iposva-google. cc @skabet. cc @sgjesse.
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.
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.
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
cc @brianquinlan for visibility
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 ?