Reputation: 657781
When I launch
io.Process.start(
'~/google_cloud_datastore_dev_server/gcd-v1beta2-rev1-2.1.1/gcd.sh')
.then((process) {
new Future.delayed(new Duration(seconds: 10), () => process.kill());
});
With Process.start
I get two new processes (the gcd.sh
script and a Java application launched from gcd.sh
). process.kill()
only kills gcs.sh
but the Java process keeps running.
Before process.kill();
pstree 24010
gcd.sh───java─┬─java───22*[{java}]
└─20*[{java}]
After process.kill();
java─┬─java───21*[{java}]
└─20*[{java}]
Is there a way to kill a process and all it's children (entire process group) from within Dart without reaching out to command line tools like ps
or similar?
It's a bit cumbersome to process command output through stdin of launched processes and also difficult to make work cross-platform when using shell commands for this task.
Seems related: http://dartbug.com/3637
Upvotes: 4
Views: 1525
Reputation: 4628
Currently there is no support for killing a process group in dart:io. I have opened http://dartbug.com/22470 to track this.
Upvotes: 3