【发布时间】:2016-01-06 02:35:27
【问题描述】:
我有以下 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 中没有信号之类的东西。使用另一种形式的 IPC。
-
好的,很高兴知道。基本上,有没有被使用这个代码呢?我可以按
Ctrl + C发送SIGINT给它。 -
是的,C 运行时模拟 SIGINT,也提供对 raise() 的支持,但不提供基于信号的 IPC。现在我想起来了,Node.js 有可能提供自己的某种信号仿真,尽管我认为这不太可能。您可以查看 Node.js 文档,或者 Node.js 专家可能会在此处加入。
-
干杯,如果我发现了什么,我会发布它。
标签: node.js windows powershell posix ipc