Skip to content

Latest commit

History

History
61 lines (46 loc) 路 2.48 KB

File metadata and controls

61 lines (46 loc) 路 2.48 KB

馃摗 Signals

Windows do not use signals like Unix does.

Terminating processes

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.

Cross-platform signals

Which signals can be used is OS-specific:

  • process.kill() can only use the following signals on Windows: SIGINT, SIGTERM, SIGKILL, SIGQUIT and 0.
  • process.on(signal) can be used on Windows cmd.exe with:
    • SIGINT: but only when hitting CTRL-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 and SIGSTKFLT 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.

Process groups

Using a negative argument with process.kill() to target a process group ID (as opposed to a PID) does not work on Windows.

Summary

Use fkill to terminate processes.

Only use:


Next (馃摗 Errors)
Previous (馃摗 Processes)
Top