@flemist/simple-tree-kill
v1.0.4
Published
Cross-platform simple tree kill processes or correct finalize multi-processes app
Downloads
32
Maintainers
Readme
@flemist/simple-tree-kill
Cross-platform process tree killer for Node.js.
Install
npm install @flemist/simple-tree-killUsage
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-killingAPI
treeKill(options)
parentsPids: (number|string)[]- processes to kill with childrenignorePids?: (number|string)[]- PIDs to skipforce: boolean- force kill vs graceful
getChildPids(options)
parentsPids: (number|string)[]- parent processesignorePids?: (number|string)[]- PIDs to skip- Returns:
Set<string>- all PIDs in tree
kill(options)
pids: (string|number)[]- processes to killforce: boolean- force kill vs graceful
autoKillChilds()
Auto-kills child processes when current process exits. Returns cleanup function.
Platform Support
- Windows:
taskkill,wmic - Unix/Linux:
kill,ps - Node.js >= 12
