1 | Tree Kill
|
2 | =========
|
3 |
|
4 | Kill all processes in the process tree, including the root process.
|
5 |
|
6 | Example
|
7 | =======
|
8 |
|
9 | Kill all the children processes of the process with pid `1`, including the process with pid `1` itself:
|
10 | ```js
|
11 | var kill = require('tree-kill');
|
12 | kill(1, 'SIGKILL');
|
13 | ```
|
14 |
|
15 | Supports callbacks with error handling:
|
16 | ```js
|
17 | var kill = require('tree-kill');
|
18 | kill(1, 'SIGKILL', function(err) {
|
19 | // Do things
|
20 | });
|
21 | ```
|
22 |
|
23 |
|
24 | Methods
|
25 | =======
|
26 |
|
27 | ## require('tree-kill')(pid, [signal], [callback]);
|
28 |
|
29 | Sends signal `signal` to all children processes of the process with pid `pid`, including `pid`. Signal defaults to `SIGTERM`.
|
30 |
|
31 | For Linux, this uses `ps -o pid --no-headers --ppid PID` to find the parent pids of `PID`.
|
32 |
|
33 | For Windows, this uses `'taskkill /pid PID /T /F'` to kill the process tree.
|
34 |
|
35 | Install
|
36 | =======
|
37 |
|
38 | With [npm](https://npmjs.org) do:
|
39 |
|
40 | ```
|
41 | npm install tree-kill
|
42 | ```
|
43 |
|
44 | License
|
45 | =======
|
46 |
|
47 | MIT
|