4 我想知道是否有可能通过单击Windows上的'X'来检测node.js进程何时关闭。如果是的话那么怎么样我试过process.on("exit");但这没有奏效。node.js能检测它何时关闭吗? 来源 2014-01-21 auragar +0 如关闭浏览器窗口或关闭Windows中的一个窗口运行的节点?其中节点正在运行的 – adeneo +0 窗口。 – auragar +1 一旦节点不再运行,它就无法检测到它没有运行。 – adeneo
4 抓SIGHUP /* * Run this code and close the Window before the 10 seconds */ var x = setTimeout(function() { console.log('hello world') }, 10000); process.on('SIGHUP', function() { console.log('About to exit'); process.exit(); }); 来源 2014-01-21 23:41:00 Daniel +0 SIGHUP工作。非常感谢。 – auragar
如关闭浏览器窗口或关闭Windows中的一个窗口运行的节点?其中节点正在运行的 – adeneo
窗口。 – auragar
一旦节点不再运行,它就无法检测到它没有运行。 – adeneo