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')
)
Asynchronously kill processes and process trees.
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.
Asynchronous kill.
Silently resolves if ESRCH is returned from process.kill(pid, signal).
-
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.
Kill process and check for PID afterwards.
-
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.
Wait lag milliseconds, then run killAndCheck.
-
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.
Process with PID exists.
pid
number PID.
Returns boolean True if the PID exists, false otherwise.