import { spawn } from 'child_process';
/**
 * Kill a process and all its children (cross-platform).
 */
export function killProcessTree(pid) {
    if (process.platform === 'win32') {
        try {
            spawn('taskkill', ['/F', '/T', '/PID', String(pid)], {
                stdio: 'ignore',
                detached: true
            });
        }
        catch {
            // Ignore errors if taskkill fails.
        }
        return;
    }
    try {
        process.kill(-pid, 'SIGKILL');
    }
    catch {
        try {
            process.kill(pid, 'SIGKILL');
        }
        catch {
            // Process already dead.
        }
    }
}
//# sourceMappingURL=tree.js.map