# tree-kill

> kill trees of processes

Latest version **1.2.2** (published 2019-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install tree-kill
pnpm add tree-kill
yarn add tree-kill
bun add tree-kill
```

Provides the command `tree-kill`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2019-12-11 |
| First published | 2013-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 359 |
| Author | Peteris Krumins |
| Maintainers | pkrumins, wmhilton |
| Keywords | tree, trees, process, processes, kill, signal |

## Links

- npm: https://www.npmjs.com/package/tree-kill
- Repository: https://github.com/pkrumins/node-tree-kill
- Issues: https://github.com/pkrumins/node-tree-kill/issues
- npm.io page: https://npm.io/package/tree-kill

## Recent versions

- 1.2.2 (latest) — 2019-12-11
- 1.2.1 — 2018-11-05
- 1.2.0 — 2017-09-19
- 1.1.0 — 2016-05-13
- 1.0.0 — 2015-09-30
- 0.1.1 — 2015-05-15
- 0.1.0 — 2015-05-09
- 0.0.6 — 2013-12-11
- 0.0.5 — 2013-07-24
- 0.0.4 — 2013-07-24
- 0.0.3 — 2013-04-11
- 0.0.2 — 2013-04-11
- 0.0.1 — 2013-04-11

## README

Tree Kill
=========

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

Examples
=======

Kill all the descendent processes of the process with pid `1`, including the process with pid `1` itself:
```js
var kill = require('tree-kill');
kill(1);
```

Send a signal other than SIGTERM.:
```js
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.
```js
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:
```sh
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
```

Methods
=======

## 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.

Install
=======

With [npm](https://npmjs.org) do:

```
npm install tree-kill
```

License
=======

MIT

Changelog
=========


## [1.2.2] - 2019-12-11
### Changed
- security fix: sanitize `pid` parameter to fix arbitrary code execution vulnerability

## [1.2.1] - 2018-11-05
### Changed
- added missing LICENSE file
- updated TypeScript definitions

## [1.2.0] - 2017-09-19
### Added
- TypeScript definitions
### Changed
- `kill(pid, callback)` works. Before you had to use `kill(pid, signal, callback)`

## [1.1.0] - 2016-05-13
### Added
- A `tree-kill` CLI

## [1.0.0] - 2015-09-17
### Added
- optional callback
- Darwin support

---
_Source: https://npm.io/package/tree-kill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
