Cross-platform simple tree kill processes or correct finalize multi-processes app
npm install @flemist/simple-tree-kill[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][github-actions-badge]][github-actions-url]
Cross-platform process tree killer for Node.js.
``bash`
npm install @flemist/simple-tree-kill
`typescript
import { treeKill, getChildPids, kill } from '@flemist/simple-tree-kill'
// Kill process and all children
treeKill({
parentsPids: [1234],
force: true
})
// Kill multiple processes, skip some PIDs
treeKill({
parentsPids: [1234, 5678],
ignorePids: [9999],
force: false
})
// Get all PIDs in tree without killing
const pids = getChildPids({
parentsPids: [1234]
})
// Kill specific PIDs only
kill({
pids: [1234, 5678],
force: true
})
// Auto-kill children on process exit
const cleanup = autoKillChilds()
// Call cleanup() to stop auto-killing
`
- processes to kill with children
- ignorePids?: (number|string)[] - PIDs to skip
- force: boolean - force kill vs graceful$3
- parentsPids: (number|string)[] - parent processes
- ignorePids?: (number|string)[] - PIDs to skip
- Returns: Set - all PIDs in tree$3
- pids: (string|number)[] - processes to kill
- force: boolean - force kill vs graceful$3
Auto-kills child processes when current process exits. Returns cleanup function.Platform Support
- Windows:
taskkill, wmic
- Unix/Linux: kill, ps`[npm-image]: https://img.shields.io/npm/v/@flemist/simple-tree-kill.svg
[npm-url]: https://npmjs.org/package/@flemist/simple-tree-kill
[node-version-image]: https://img.shields.io/node/v/@flemist/simple-tree-kill.svg
[node-version-url]: https://nodejs.org/en/download/
[github-actions-badge]: https://github.com/NikolayMakhonin/simple-tree-kill/actions/workflows/build.yml/badge.svg
[github-actions-url]: https://github.com/NikolayMakhonin/simple-tree-kill/actions
[downloads-image]: https://img.shields.io/npm/dm/@flemist/simple-tree-kill.svg
[downloads-url]: https://npmjs.org/package/@flemist/simple-tree-kill
[npm-url]: https://npmjs.org/package/@flemist/simple-tree-kill