【发布时间】:2019-03-04 09:41:05
【问题描述】:
当系统将其电源状态更改为睡眠时,是否可以得到通知?
类似
process.on('sleep', () => foo())
进入睡眠状态时,进程不会被杀死或退出,因此来自 doing a cleanup action just before node.js exits不要受苦。
【问题讨论】:
标签: javascript node.js process
当系统将其电源状态更改为睡眠时,是否可以得到通知?
类似
process.on('sleep', () => foo())
进入睡眠状态时,进程不会被杀死或退出,因此来自 doing a cleanup action just before node.js exits不要受苦。
【问题讨论】:
标签: javascript node.js process
您的程序从signals 接收来自Linux 操作系统的信息。我猜您正在寻找的信号来自以下列表:
在 node.js here 中处理信号就是你的做法:
// Begin reading from stdin so the process does not exit.
process.stdin.resume();
process.on('SIGINT', () => {
console.log('Received SIGINT. Press Control-D to exit.');
});
// Using a single function to handle multiple signals
function handle(signal) {
console.log(`Received ${signal}`);
}
process.on('SIGINT', handle);
process.on('SIGTERM', handle);
【讨论】: