Skip to content Skip to sidebar Skip to footer

Node.js: Sigint Sent From Process.kill() Can't Be Handled

I'm using Node.js v0.10.31 on Windows 8.1 x64. I noticed that for a process (a node.js or python script) that handles the SIGINT handler, the handler is not called when the signal

Solution 1:

It seems like it's not the problem of Node.js that sends SIGINT, but rather a Windows platform issue. That's because when I send SIGINT from a python program, it also unconditionally terminates the process that handles the SIGINT event:

os.kill(pid, signal.SIGINT)

Luckily Python documents this better:

os.kill(pid, sig)

Send signal sig to the process pid. Constants for the specific signals available on the host platform are defined in the signal module.

Windows: The signal.CTRL_C_EVENT and signal.CTRL_BREAK_EVENT signals are special signals which can only be sent to console processes which share a common console window, e.g., some subprocesses. Any other value for sig will cause the process to be unconditionally killed by the TerminateProcess API, and the exit code will be set to sig. The Windows version of kill() additionally takes process handles to be killed.

Post a Comment for "Node.js: Sigint Sent From Process.kill() Can't Be Handled"