0

コマンド ライン インターフェイス ( hyperTerminalWindows 用) でプロセス ID を使用してプロセスを強制終了すると、" Why are you trying to terminate me?!? :-)" を持つコールバック関数がコンソールに反映されません。

最初のシェルでは、実行node myfilename.js 後にコマンドを使用して実行しています。出力は次 のようになります。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