1.0.0 • Published 3 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.signal
string Kill signal. (optional, default'SIGTERM'
)options
Object 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
pid
number PID.signal
string Kill signal. (optional, default'SIGTERM'
)options
Object Additional options. (optional, default{}
)options.recursive
boolean 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
pid
number PID.signal
string Kill signal. (optional, default'SIGTERM'
)options
Object Additional options. (optional, default{}
)options.recursive
boolean 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
pid
number PID.signal
string Kill signal. (optional, default'SIGTERM'
)options
Object Additional options. (optional, default{}
)options.recursive
boolean 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
pid
number PID.
Returns boolean True if the PID exists, false otherwise.
1.0.0
3 years ago