import { type KnownProcessIdentity, type ProcessIdentityComparison, type ProcessIdentityReader, type ProcessIdentityUnknownReason } from "./process-identity.js"; declare const processGroupHandleBrand: unique symbol; export type ProcessGroupHandle = Readonly<{ schemaVersion: 1; pgid: number; leader: KnownProcessIdentity; [processGroupHandleBrand]: true; }>; export type ProcessGroupCapture = { status: "known"; handle: ProcessGroupHandle; } | { status: "missing"; pid: number; } | { status: "unknown"; pid: number; reason: ProcessIdentityUnknownReason | "identity_pid_mismatch" | "not_process_group_leader"; }; export type ProcessGroupEmptyProbe = { status: "empty"; pgid: number; } | { status: "nonempty"; pgid: number; } | { status: "unknown"; pgid: number; reason: "unsupported_platform" | "permission_denied" | "probe_failed"; }; /** Outcome of the injected win32 tree kill (`taskkill /T /F` in production). */ export type ProcessTreeKillOutcome = "killed" | "not_found" | "failed"; export type ProcessGroupSignalResult = { status: "sent"; pgid: number; signal: NodeJS.Signals; } | { status: "empty"; pgid: number; signal: NodeJS.Signals; } | { status: "unknown"; pgid: number; signal: NodeJS.Signals; reason: "stale_leader" | "missing_leader" | "identity_unknown" | "permission_denied" | "signal_failed" | "unsupported_platform"; }; export interface ProcessGroupServiceOptions { platform?: string; identity?: ProcessIdentityReader; probeProcessGroup?: (negativePgid: number) => void; signalProcessGroup?: (negativePgid: number, signal: NodeJS.Signals) => void; /** * OPT-IN win32 terminator (`killWindowsProcessTree` in production). Windows * has no process groups and no cooperative signal, so a win32 `signal` is a * whole-tree kill of the recorded leader. Absent (the default) keeps win32 * signalling refused, so no consumer inherits Windows termination it did not * ask for. The caller injects it from the tree owner, which keeps this * module a leaf. */ killProcessTree?: (pid: number) => ProcessTreeKillOutcome; } export declare function parseProcessGroupHandle(value: unknown): ProcessGroupHandle; export declare class ProcessGroupService { private readonly platform; private readonly identity; private readonly probeProcessGroup; private readonly signalProcessGroup; private readonly killProcessTree?; constructor(options?: ProcessGroupServiceOptions); captureLeader(pid: number): ProcessGroupCapture; compareLeader(handle: ProcessGroupHandle): ProcessIdentityComparison; /** * Only ESRCH proves the complete group empty; every other error is unknown. * On win32 there is no group probe: emptiness is the recorded LEADER's * kernel identity being gone (missing, or a different process on a recycled * pid) after the tree kill that `signal` performs — a leader-death proof, * weaker than the POSIX group proof and disclosed as such by its own owner. */ probeEmpty(handle: ProcessGroupHandle): ProcessGroupEmptyProbe; /** Refuses to signal unless the exact recorded leader identity still owns the PGID. */ signal(handle: ProcessGroupHandle, signal: NodeJS.Signals): ProcessGroupSignalResult; } export declare const defaultProcessGroupService: ProcessGroupService; export {}; //# sourceMappingURL=process-group.d.ts.map