Tag: 暂停

如何挂起SIGTSTOP上的node.js进程

我正在构build一个node.js中的小工具,它需要监听按键来执行一些function。 为此我使用keypress库。 我知道如何设置关键侦听器并侦听ctrl + C组合键来退出进程(使用process.exit() ): import keypress from 'keypress'; const stdin = process.stdin; keypress(process.stdin); process.stdin.setRawMode(true); process.stdin.on('keypress', function(ch, key) { if ( key && key.ctrl ) if ( key.name == 'c') { console.log('quitting…'); process.exit(); } else { console.log('suspending…'); // WHAT TO DO? } } else if ( ch ) { my_functionality(ch); } }); 我也听ctrl + […]