export interface ProcessTree { /** Every descendant pid (including `root`), deepest-first. */ pids: number[]; /** * Every distinct process-group id found in the tree, excluding the caller's * own group. A child that ran `set -m` (bash monitor mode) or `setsid` leads * its own group, so signalling the root's group alone would miss it. */ pgids: number[]; } export interface PsRow { pid: number; ppid: number; pgid: number; /** Full command line. Empty when the snapshot was taken without it. */ command: string; } /** * One `ps` snapshot of every process on the machine, with command lines. * Exposed so a caller that needs several trees (the session tracker walks one * per managed process) pays for a single `ps` instead of one per root. */ export declare function snapshotAll(): Promise; /** * The full descendant tree of `root`, captured from ONE `ps` snapshot. * * This must be taken **before** any signal is sent. Killing a parent first and * walking `ppid` afterwards (what `tree-kill` does) loses the whole subtree: * the moment the parent dies its children reparent to init, so the walk finds * nothing and they survive as orphans. Capturing first makes the set of * targets immune to the reparenting the signals themselves cause. * * Also returns the distinct process groups in the tree, because a wrapper * script that runs `set -m` (bash monitor mode — common in dev scripts) puts * each job in its own group that the root's group signal never reaches. * * The caller's own pid, its group, and pid 1 are always excluded: this * function's output is fed straight to `kill`, so it must never be able to * target orckit itself or init. */ export declare function collectProcessTree(root: number): Promise; /** Build a tree from an already-taken {@link snapshotAll} table. */ export declare function treeFrom(rows: PsRow[], root: number): ProcessTree; /** * The tree of `root` as (pid, command) pairs plus its process groups. * * Recording the command alongside each pid is what makes killing a remembered * tree safe later: PIDs are recycled, so a member is only ever signalled if the * process living under that pid still runs the command we saw. */ export declare function detailedTreeFrom(rows: PsRow[], root: number): { members: Array<{ pid: number; command: string; }>; pgids: number[]; }; /** * Blocking variant of {@link collectProcessTree}, for the emergency paths * (double Ctrl-C, uncaughtException) that must finish before `process.exit()` * and cannot await. Returns just the root on any failure — the caller still * signals that, so a broken `ps` degrades to the old behavior instead of * throwing inside a crash handler. */ export declare function collectProcessTreeSync(root: number): ProcessTree; /** Merge two snapshots, preserving the deepest-first ordering of `a`. */ export declare function mergeTrees(a: ProcessTree, b: ProcessTree): ProcessTree; /** * Signal every process group in the tree, then every individual pid. Groups * first because that reaches processes forked between the snapshot and now; * the per-pid pass then catches anything whose group we somehow missed. * Best-effort throughout — an already-dead pid is a success, not an error. */ export declare function signalTree(tree: ProcessTree, signal: NodeJS.Signals): void; /** The subset of `tree.pids` that is still alive. */ export declare function survivors(tree: ProcessTree): number[]; //# sourceMappingURL=process-tree.d.ts.map