@cocalc/backend
Version:
CoCalc backend functionality: functionality used by either the hub, the next.js server or the project.
34 lines • 1.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = __importDefault(require("@cocalc/backend/logger"));
const logger = (0, logger_1.default)("process-kill");
// sends kill 2,3,9 signal to pid.
// never raises an exception.
function processKill(pid, signal) {
let s;
switch (signal) {
case 2:
s = "SIGINT";
break;
case 3:
s = "SIGQUIT";
break;
case 9:
s = "SIGKILL";
break;
default:
logger.debug("WARNING -- process_kill: only signals 2 (SIGINT), 3 (SIGQUIT), and 9 (SIGKILL) are supported");
return;
}
try {
logger.debug("process.kill -- pid=", pid, " signal=", signal);
process.kill(pid, s);
}
catch (_err) { }
}
exports.default = processKill;
// it's normal to get an exception when sending a signal... to a process that doesn't exist.
//# sourceMappingURL=process-kill.js.map