【发布时间】:2016-10-18 20:33:21
【问题描述】:
您好,我正在使用 child_process.spwan 来启动在 Windows 上运行 python 脚本的子进程。该脚本侦听 SIGINT 以优雅地退出。但是 Windows 不支持信号,所有节点都在模拟。所以 Windows 上的child_process.kill('SIGINT') 实际上是无条件地终止进程(没有优雅退出,python 的 SIGTERM/SIGINT 处理程序没有被调用)。将ctrl+c 字符写入标准输入也不起作用。
当我研究 Python API 时,我得到了可以满足需求的 CTRL_BREAK_EVENT 和 CTRL_C_EVENT。我想知道 node 是否有类似的等价的特定于平台的 API?
相关帖子但无效的帖子: How to send control C node.js and child_processes sending crtl+c to a node.js spawned childprocess using stdin.write()?
【问题讨论】:
标签: node.js windows signals child-process