method Process.kill
Usage in Deno
import { type Process } from "node:process";
Process.kill(pid: number,signal?: string | number,): true
The process.kill()
method sends the signal
to the process identified bypid
.
Signal names are strings such as 'SIGINT'
or 'SIGHUP'
. See Signal Events
and kill(2)
for more information.
This method will throw an error if the target pid
does not exist. As a special
case, a signal of 0
can be used to test for the existence of a process.
Windows platforms will throw an error if the pid
is used to kill a process
group.
Even though the name of this function is process.kill()
, it is really just a
signal sender, like the kill
system call. The signal sent may do something
other than kill the target process.
import process, { kill } from 'node:process'; process.on('SIGHUP', () => { console.log('Got SIGHUP signal.'); }); setTimeout(() => { console.log('Exiting.'); process.exit(0); }, 100); kill(process.pid, 'SIGHUP');
When SIGUSR1
is received by a Node.js process, Node.js will start the
debugger. See Signal Events
.
true