import { spawnSync } from "node:child_process"; export interface ProcessTreeKillOptions { platform?: NodeJS.Platform; kill?: typeof process.kill; spawnSync?: typeof spawnSync; env?: NodeJS.ProcessEnv; taskkillTimeoutMs?: number; } /** * Absolute path to `taskkill.exe`. * * Bare `"taskkill"` depends on `System32` being on PATH — not guaranteed for a * GUI-launched app whose PATH we also mutate — and is spoofable by a * `taskkill.exe` sitting in the project cwd. Resolve it from `SystemRoot` * (falling back to `WINDIR`, then `C:\Windows`), rejecting anything that isn't * a plain drive-rooted path. */ export declare function resolveWindowsTaskkillPath(env?: NodeJS.ProcessEnv): string; /** * Kill a process and every descendant. * * POSIX: SIGKILL the process group (negative pid), falling back to the single * pid. Windows has no process groups and negative pids are invalid there — the * POSIX path silently left the whole child tree running, so a timed-out or * cancelled `bash` command kept its `npm`/`node`/`pnpm` descendants alive * forever. Use `taskkill /T /F` instead, falling back to the direct pid. */ export declare function killProcessTree(pid: number, options?: ProcessTreeKillOptions): void; export interface ProcessTableOptions { platform?: NodeJS.Platform; /** Injected for tests: returns `[pid, ppid]` pairs for every process. */ readTable?: () => Array<[number, number]>; } /** * Every live descendant of `pid` (breadth-first, excluding `pid` itself), * found by parent links — so it also covers children that left the process * group, unlike a group kill. POSIX only; returns `[]` on Windows, where * shell pids (msys) do not map onto the native process table. */ export declare function listDescendantPids(pid: number, options?: ProcessTableOptions): number[]; /** * Signal every descendant of `pid` without touching `pid` itself — stops a * persistent shell's running command while the shell survives. Returns how * many processes were signalled. */ export declare function signalDescendants(pid: number, signal: NodeJS.Signals, options?: ProcessTableOptions & { kill?: typeof process.kill; }): number;