0

在命令行界面(hyperTerminal对于 Windows)中使用进程 ID 终止进程时,具有“ Why are you trying to terminate me?!? :-)”的回调函数不会反映在控制台中。

在我运行node myfilename.js 后使用命令运行的第一个 shell 中,我得到的输出为: Node is running as process #processid

并杀死这个进程,我运行命令:taskkill /F /PID processid 在不同的外壳

代码如下:

process.stdin.resume();
process.stdin.setEncoding('utf8');


process.on('SIGTERM', function() {
    process.stderr.write("Why are you trying to terminate me?!?  :-)\n");
});

console.log("Node is running as process #" + process.pid);

运行我的命令后,该过程将终止并显示以下消息: SUCCESS: The process with PID processid has been terminated.

但在控制台中我没有得到所需的输出(Why are you trying to terminate me?!? :-))。

4

0 回答 0