1.0.0 • Published 5 years ago
tmbr v1.0.0
tmbr
Kill processes and process trees.
Simple use cases:
const tmbr = require('tmbr');
// Kill PID 1337 (using SIGTERM) and all of its children
tmbr(1337)
// Use SIGKILL instead
tmbr(1337, 'SIGKILL')
// Try to kill a stubborn process 3 times with SIGTERM,
// then if the process is still alive, send a SIGKILL
tmbr(
1337, 'SIGTERM', {retries:2}
).catch(
() => tmbr(1337, 'SIGKILL')
)API
Table of Contents
tmbr
Asynchronously kill processes and process trees.
Parameters
p(child_process.ChildProcess | number) Child process or PID.signalstring Kill signal. (optional, default'SIGTERM')optionsObject Additional options. (optional, default{})
Returns Promise<Object> Promise with information about the process tree.
tmbr/util
asyncKill
Asynchronous kill.
Silently resolves if ESRCH is returned from process.kill(pid, signal).
Parameters
pidnumber PID.signalstring Kill signal. (optional, default'SIGTERM')optionsObject Additional options. (optional, default{})options.recursiveboolean Recursive kill.
- Throws any If pid is invalid.
Returns Promise<Object> Resolves if PID kill did not error, rejects otherwise.
killAndCheck
Kill process and check for PID afterwards.
Parameters
pidnumber PID.signalstring Kill signal. (optional, default'SIGTERM')optionsObject Additional options. (optional, default{})options.recursiveboolean Recursive kill.
- Throws any If pid is invalid.
Returns Promise<Object> Resolves if PID kill was successful, rejects otherwise.
lagKill
Wait lag milliseconds, then run killAndCheck.
Parameters
pidnumber PID.signalstring Kill signal. (optional, default'SIGTERM')optionsObject Additional options. (optional, default{})options.recursiveboolean Recursive kill.
lag(optional, default0)
- Throws any If pid is invalid.
Returns Promise Resolves if PID kill was successful, rejects otherwise.
processExists
Process with PID exists.
Parameters
pidnumber PID.
Returns boolean True if the PID exists, false otherwise.
1.0.0
5 years ago