Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not kill child process on MacOS #28

Open
barnabasbartha opened this issue Sep 11, 2019 · 3 comments
Open

Does not kill child process on MacOS #28

barnabasbartha opened this issue Sep 11, 2019 · 3 comments

Comments

@barnabasbartha
Copy link

In some cases I want to kill a child process spawned from node, but even if I use this package giving the process's PID number, the process lives happily and does not close. Any idea?

@samuelpetroline
Copy link

Does the callback function gets executed?

var kill = require('tree-kill');
kill(1, 'SIGKILL', function(err) {
    // Do things
});

@yantze
Copy link

yantze commented Sep 10, 2020

Same problem in mac. The default SIGTERM cause self pid can not be killed. SIGKILL will kill self pid.

This is also work:

kill(1, function(err) {
    // Do things
    setTimeout(() => {
      process.kill(1)
    }, 200)
});

@Izhaki
Copy link

Izhaki commented Apr 26, 2021

Same issue here.
I've found out that the solution by ps-tree works:

psTree(child.pid, function (err, children) {
  cp.spawn('kill', ['-9'].concat(children.map(function (p) { return p.PID })));
});

I do wonder if there's much point for this package to replicate the logic already in ps-tree? Just have ps-tree as a dependency and use in buildProcessTree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants