事件:'SIGTSTP'
¥Event: 'SIGTSTP'
当 input
流接收到 Ctrl+Z 输入(通常称为 SIGTSTP
)时,会触发 'SIGTSTP'
事件。如果 input
流接收到 SIGTSTP
时没有注册 'SIGTSTP'
事件监听器,则 Node.js 进程将被发送到后台。
¥The 'SIGTSTP'
event is emitted when the input
stream receives
a Ctrl+Z input, typically known as SIGTSTP
. If there are
no 'SIGTSTP'
event listeners registered when the input
stream receives a
SIGTSTP
, the Node.js process will be sent to the background.
当使用 fg(1p)
恢复程序时,则将触发 'pause'
和 'SIGCONT'
事件。这些可用于恢复 input
流。
¥When the program is resumed using fg(1p)
, the 'pause'
and 'SIGCONT'
events
will be emitted. These can be used to resume the input
stream.
如果 input
在进程发送到后台之前暂停,则不会触发 'pause'
和 'SIGCONT'
事件。
¥The 'pause'
and 'SIGCONT'
events will not be emitted if the input
was
paused before the process was sent to the background.
调用监听器函数时不传入任何参数。
¥The listener function is invoked without passing any arguments.
rl.on('SIGTSTP', () => {
// This will override SIGTSTP and prevent the program from going to the
// background.
console.log('Caught SIGTSTP.');
});
Windows 不支持 'SIGTSTP'
事件。
¥The 'SIGTSTP'
event is not supported on Windows.