lib/utils/process.js
function kill(p, sig) {
  if (isWin) {
    let command = 'taskkill.exe';
    let args = ['/t', '/pid', p.pid];
    if (sig === 'SIGKILL') {
      args.push('/f');
    }

    execa(command, args).then(result => {
      // Processes without windows can't be killed without /F, detect and force
      // kill them directly
      if (result.stderr.indexOf('can only be terminated forcefully') !== -1) {
        kill(p, 'SIGKILL');
      }
    }).catch(err => {
      log.error(err);
    });
  } else {
    p.kill(sig);
  }
}
function kill(p, sig) {
  if (isWin) {
    let command = 'taskkill.exe';
    let args = ['/t', '/pid', p.pid];
    if (sig === 'SIGKILL') {
      args.push('/f');
    }

    execa(command, args).then(result => {
      // Processes without windows can't be killed without /F, detect and force
      // kill them directly
      if (result.stderr.indexOf('can only be terminated forcefully') !== -1) {
        kill(p, 'SIGKILL');
      }
    }).catch(err => {
      log.error(err);
    });
  } else {
    p.kill(sig);
  }
}
function kill ( p , sig ) { if ( isWin ) { let command = 'taskkill.exe' ; let args = [ '/t' , '/pid' , p . pid ] ; if ( sig === 'SIGKILL' ) { args . push ( '/f' ) ; } execa ( command , args ) . then ( result => { // Processes without windows can't be killed without /F, detect and force // kill them directly if ( result . stderr . indexOf ( 'can only be terminated forcefully' ) !== - 1 ) { kill ( p , 'SIGKILL' ) ; } } ) . catch ( err => { log . error ( err ) ; } ) ; } else { p . kill ( sig ) ; } }
Kill process and all child processes cross platform
Kill process and all child processes cross platform