kill trees of processes
Clone or download
Latest commit 6d6843c Apr 6, 2018

Tree Kill

Kill all processes in the process tree, including the root process.


Kill all the descendent processes of the process with pid 1, including the process with pid 1 itself:

var kill = require('tree-kill');

Send a signal other than SIGTERM.:

var kill = require('tree-kill');
kill(1, 'SIGKILL');

Run a callback when done killing the processes. Passes an error argument if there was an error.

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

You can also install tree-kill globally and use it as a command:

tree-kill 1          # sends SIGTERM to process 1 and its descendents
tree-kill 1 SIGTERM  # same
tree-kill 1 SIGKILL  # sends KILL instead of TERMINATE


require('tree-kill')(pid, [signal], [callback]);

Sends signal signal to all children processes of the process with pid pid, including pid. Signal defaults to SIGTERM.

For Linux, this uses ps -o pid --no-headers --ppid PID to find the parent pids of PID.

For Darwin/OSX, this uses pgrep -P PID to find the parent pids of PID.

For Windows, this uses 'taskkill /pid PID /T /F' to kill the process tree. Note that on Windows, sending the different kinds of POSIX signals is not possible.


With npm do:

npm install tree-kill




[1.2.0] - 2017-19-09


  • TypeScript definitions


  • kill(pid, callback) works. Before you had to use kill(pid, signal, callback)

[1.1.0] - 2016-05-13


  • A tree-kill CLI

[1.0.0] - 2015-09-17


  • optional callback
  • Darwin support