node.js怎么监听程序强制退出

如题所述

nodejs中可以通过监听信号量的来监听程序的退出
例如 SIGINT 监听ctrl-D/Control-C退出程序
process.on('SIGINT', function() {
console.log('Got SIGINT. Press Control-D/Control-C to exit.');
});
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-12-15
nodejs中可以通过监听信号量的来监听程序的退出
例如 SIGINT 监听ctrl-D/Control-C退出程序
process.on('SIGINT', function() {
console.log('Got SIGINT. Press Control-D/Control-C to exit.');
});本回答被网友采纳