/**
 * pid.mjs — PID liveness + lock-staleness helpers (C29).
 */
/**
 * Check if a PID is alive (Unix only — uses kill(pid, 0) signal check).
 */
export function isPidAlive(pid) {
    try {
        process.kill(pid, 0);
        return true;
    }
    catch {
        return false;
    }
}
/**
 * Check if a lock is stale: heartbeat > 2 min old AND PID is dead.
 */
export function isLockStale(lockData) {
    const heartbeatAge = Date.now() - new Date(lockData.heartbeat).getTime();
    const ttlMs = (lockData.ttl_seconds || 120) * 1000;
    if (heartbeatAge <= ttlMs)
        return false;
    return !isPidAlive(lockData.worker_pid);
}
//# sourceMappingURL=pid.mjs.map