export interface PortableSpawnOptions { cwd?: string; env?: Record; detached?: boolean; } /** * Options for {@link portableSpawnSync}. * * `timeoutMs` is **required**, and deliberately so. A synchronous spawn blocks * the single-threaded event loop until the child exits; if the child stalls — * classically on a wedged network/FUSE mount reachable from `cwd` — the whole * process stops serving. An unbounded `spawnSync` is therefore not a call that * should be expressible, so the deadline is part of the type rather than an * optional extra a caller can forget. */ export interface PortableSpawnSyncOptions extends PortableSpawnOptions { /** Wall-clock limit for the child, in milliseconds. Must be > 0. */ timeoutMs: number; } /** A spawned process with stdout/stderr piped. Mirrors the shape of `Bun.Subprocess`. */ export interface PortableSubprocess { /** OS process id, or -1 if the process failed to spawn. */ readonly pid: number; readonly stdout: ReadableStream; readonly stderr: ReadableStream; /** * Resolves with the exit code once the process closes. Signal termination * uses the conventional `128 + signal number`; spawn errors or unknown * signals use `-1`. */ readonly exited: Promise; kill(signal?: number | NodeJS.Signals): void; } export interface PortableSpawnSyncResult { /** Exit code; -1 when the process did not exit cleanly. */ exitCode: number; stdout: string; stderr: string; /** * `true` when the child was killed for exceeding * {@link PortableSpawnSyncOptions.timeoutMs}. Lets a caller tell "the command * failed" apart from "the command never finished", which are different * operational events. */ timedOut: boolean; } /** * Spawn a subprocess with stdout/stderr piped. Works under Node and Bun. * * @param cmd - Command and arguments, e.g. `["docker", "ps"]`. */ export declare function portableSpawn(cmd: string[], opts?: PortableSpawnOptions): PortableSubprocess; /** * Run a subprocess to completion synchronously, capturing stdout/stderr as * UTF-8 strings. Works under Node and Bun. * * Blocks the event loop for the child's whole lifetime, so `opts.timeoutMs` * is required — see {@link PortableSpawnSyncOptions}. Prefer * {@link portableSpawn} wherever an async call is possible; only reach for this * when the caller genuinely cannot await (process teardown, CLI entry points). * * The child is killed with `SIGKILL` rather than `SIGTERM` on expiry: a process * blocked in an uninterruptible kernel wait (`D` state, e.g. a dead FUSE * connection) never runs a `SIGTERM` handler, so a graceful signal would leave * the deadline unenforced. * * @param cmd - Command and arguments, e.g. `["docker", "info"]`. * @param opts - Spawn options; `timeoutMs` is mandatory. */ export declare function portableSpawnSync(cmd: string[], opts: PortableSpawnSyncOptions): PortableSpawnSyncResult; //# sourceMappingURL=subprocess.d.ts.map