"use strict";
/**
 * Process management utilities
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.killWithEscalation = void 0;
/**
 * Kill process with SIGTERM, escalating to SIGKILL if it doesn't exit.
 * Uses exitCode === null (not proc.killed) to check if process is still running,
 * since proc.killed only indicates a signal was sent, not that the process exited.
 */
function killWithEscalation(proc, gracePeriodMs = 3000) {
    proc.kill('SIGTERM');
    const timer = setTimeout(() => {
        if (proc.exitCode === null) {
            proc.kill('SIGKILL');
        }
    }, gracePeriodMs);
    timer.unref(); // Don't keep event loop alive just for escalation
    proc.once('exit', () => clearTimeout(timer));
}
exports.killWithEscalation = killWithEscalation;
//# sourceMappingURL=process-utils.js.map