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
,SIGQUIT
and0
.process.on(signal)
can be used on Windowscmd.exe
with:SIGINT
: but only when hittingCTRL-C
SIGBREAK
: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
,SIGPWR
andSIGSTKFLT
can only be used on Linux.SIGINFO
can 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
,SIGQUIT
and0
.process.on(signal)
withSIGINT
,SIGHUP
andSIGWINCH
.