在 Windows 中发送 SIGUSR1 IPC
Sending SIGUSR1 IPC in Windows
我有以下 NodeJS 代码:
setInterval(function() {}, 1e6);
process.on('SIGUSR1', function() {
console.log('Got a signal');
});
在 Unix 中我应该能够使用kill -s SIGUSR1 1234
发送这个信号。 Windows 没有 kill
命令,我可以看到 Powershell 有,但它似乎没有类似 -s 的选项。
NAME
Stop-Process
SYNTAX
Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
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.
那么,如何在 Windows 中发送 SIGUSR1
信号?
如前所述,Windows 不支持 UNIX 信号。
但是,SIGUSR1 在 nodejs 中用于在已经 运行 的进程上启动调试器,如果这是您想要的功能,您可以使用未记录的 api:
process._debugProcess(pid);
这将在进程上启动调试器。
我有以下 NodeJS 代码:
setInterval(function() {}, 1e6);
process.on('SIGUSR1', function() {
console.log('Got a signal');
});
在 Unix 中我应该能够使用kill -s SIGUSR1 1234
发送这个信号。 Windows 没有 kill
命令,我可以看到 Powershell 有,但它似乎没有类似 -s 的选项。
NAME
Stop-Process
SYNTAX
Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
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.
那么,如何在 Windows 中发送 SIGUSR1
信号?
如前所述,Windows 不支持 UNIX 信号。
但是,SIGUSR1 在 nodejs 中用于在已经 运行 的进程上启动调试器,如果这是您想要的功能,您可以使用未记录的 api: process._debugProcess(pid);
这将在进程上启动调试器。