鉴于我做了类似的事情:
shelljs.exec('someLongrunningCommand', {async: true})
如何在同一个脚本中发送SIGINT或以其他方式取消此过程?
答案 0 :(得分:0)
您可以通过 subprocess.kill()方法发送SIGINT或SIGHUP信号来取消该过程,如下所示:
const shell = require('shelljs');
let process = shell.exec('someLongrunningCommand', { async: true });
// Here you stop the process
process.kill('SIGINT');