UNPKG

cross-spawn-with-kill

Version:

Adds cross-platform `kill` function to cross-spawn processes

28 lines (23 loc) 490 B
'use strict'; var getDescendentProcessInfo = require('ps-tree'); module.exports = killPosix; /** * Kills the new process and its sub processes. * @this ChildProcess * @returns {void} */ function killPosix() { getDescendentProcessInfo(this.pid, function (err, descendent) { if (err) { return; } descendent.forEach(function (_ref) { var pid = _ref.PID; try { process.kill(pid); } catch (_err) { // ignore. } }); }); }