Windows do not use signals like Unix does.
However processes can be terminated using the
taskkill
command. The taskkill project can
be used to do it from Node.js. fkill
builds on it to terminate processes on any OS.
Which signals can be used is OS-specific:
process.kill()can only use the following signals on Windows:SIGINT,SIGTERM,SIGKILL,SIGQUITand0.process.on(signal)can be used on Windowscmd.exewith:SIGINT: but only when hittingCTRL-CSIGBREAK:CTRL-BREAK. However, this signal only works on Windows.SIGHUP: closing the window. The process is terminated after 10 seconds.SIGWINCH: resizing the terminal. This will only be triggered on Windows when the cursor moves on when a terminal in raw mode is used.
SIGPOLL,SIGPWRandSIGSTKFLTcan only be used on Linux.SIGINFOcan only be used on Mac.
Each signal has both an OS-agnostic name and an OS-specific integer constant.
process.kill()
can use either. It is possible to convert between both using
os.constants.signals.
However it is more cross-platform to use signal names instead of integer
constants.
Using a negative argument with
process.kill()
to target a process group ID (as opposed to
a PID) does not work on Windows.
Use fkill to terminate processes.
Only use:
process.kill()withSIGINT,SIGTERM,SIGKILL,SIGQUITand0.process.on(signal)withSIGINT,SIGHUPandSIGWINCH.