Is it possible to signal yourself in Node.js?

2019-07-24 09:32发布

问题:

I know it's possible to send SIGTERM, SIGINT, etc. to your own process in the C programming language:

https://www.gnu.org/software/libc/manual/html_node/Signaling-Yourself.html

Does Node.js provide this functionality?

回答1:

process.kill(process.pid, "SIGINT");

process.kill sends a signal (SIGINT in this case, provided by the second parameter), to a provided PID. (process.pid in this case, which is the PID of the running node process.)

Source: https://nodejs.org/api/process.html#process_process_kill_pid_signal