Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill process group

Tags:

dart

dart-io

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

like image 967
Günter Zöchbauer Avatar asked Sep 15 '25 02:09

Günter Zöchbauer


1 Answers

Currently there is no support for killing a process group in dart:io. I have opened http://dartbug.com/22470 to track this.

like image 200
sgjesse Avatar answered Sep 17 '25 01:09

sgjesse