2

Given I do something like:

shelljs.exec('someLongrunningCommand', {async: true})

How can I send a SIGINT or otherwise cancel this process in the same script?

csvan
  • 8,782
  • 12
  • 48
  • 91

1 Answers1

4

You can cancel the process by sending a SIGINT or SIGHUP signal with subprocess.kill() methods like this:

const shell = require('shelljs');

let process = shell.exec('someLongrunningCommand', { async: true });

// Here you stop the process
process.kill('SIGINT');
TGrif
  • 5,725
  • 9
  • 31
  • 52