Question:
I have the following NodeJS code:
1 2 3 4 5 |
setInterval(function() {}, 1e6); process.on('SIGUSR1', function() { console.log('Got a signal'); }); |
In Unix I should be able to use kill -s SIGUSR1 1234
to send this signal. Windows doesn’t have a kill
command, I can see that Powershell does but it doesn’t seem to have a -s like option.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
NAME Stop-Process SYNTAX Stop-Process [-Id] Stop-Process -Name Stop-Process [-InputObject] ALIASES spps kill REMARKS Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help. -- To download and install Help files for the module that includes this cmdlet, use Update-Help. -- To view the Help topic for this cmdlet online, type: "Get-Help Stop-Process -Online" or go to http://go.microsoft.com/fwlink/?LinkID=113412. |
So, how to I send a SIGUSR1
signal in Windows?
Answer:
As was already mentioned Windows does not support UNIX signals.
But, SIGUSR1 is used in nodejs for starting the debugger on an already running process, if this is the functionality you were after, you could use the undocumented api:
process._debugProcess(pid);
This will start the debugger on the process.