/** * @file * * Pure helpers for answering "which process is still holding this port?". * * A teardown that cannot answer that question can only re-issue the same kill at * the same PID, which is no escalation at all: the PID the harness holds is the * shell wrapper it spawned, and what survives is whatever that wrapper's tree * walk failed to reach. The port, by contrast, is direct evidence — a socket * still answering on 4723 after this run killed the server it started belongs to * that server. * * Kept separate from the integration-only `transport-factory` so the parsing * stays unit-testable; the factory shells out to `netstat` / `lsof`. */ /** * Parameters for {@link parseWindowsNetstatPids}. */ export interface ParseWindowsNetstatPidsParams { /** Raw stdout of `netstat -ano`. */ readonly netstatOutput: string; /** The local port whose listener is wanted. */ readonly port: number; } /** * Parses `lsof -ti tcp:` output, which is already one PID per line. * * @param lsofOutput - Raw stdout of the `lsof` query. * @returns The distinct PIDs, in listed order. */ export declare function parsePosixLsofPids(lsofOutput: string): number[]; /** * Parses `netstat -ano` output for the PIDs **listening** on a port. * * Only `TCP` rows in the `LISTENING` state count: an established connection *to* * the port belongs to a client, not to the server that must die, and the `UDP` * rows have no state column at all. The same server appears twice when it binds * both IPv4 and IPv6, so PIDs are de-duplicated. * * @param params - The listing output and the port to match. * @returns The distinct listening PIDs, in listed order. */ export declare function parseWindowsNetstatPids(params: ParseWindowsNetstatPidsParams): number[];