UNPKG

kill-sync

Version:

Cross-platform kill command. Supports recusive/tree-kill in a synchronous manner.

31 lines 997 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const treekill_1 = require("./treekill"); /** * Kills a process with the given PID. * * @param {number} pid - The process ID to kill. * @param {string | number} [signal='SIGTERM'] - signal to send to the process * @param {boolean} [recursive=false] - pass true for tree kill * * @returns {void} */ const killSync = (pid, signal, recursive = false) => { signal = signal !== null && signal !== void 0 ? signal : 'SIGTERM'; if (!recursive) { return (0, treekill_1.killPid)(pid, signal); } /* istanbul ignore next */ switch (process.platform) { case 'win32': (0, child_process_1.execSync)(`taskkill /pid ${pid} /T /F`); break; case 'darwin': default: (0, treekill_1.treeKill)(pid, signal); break; } }; exports.default = killSync; //# sourceMappingURL=kill.js.map