Skip to content

Type Alias: ChildProcessResult

ChildProcessResult = ChildProcess & Promise<ExecResult>

What spawn returns: the LIVE ChildProcess handle that is ALSO a Promise<ExecResult> resolving on exit.

This is additive - the object still satisfies Promise<ExecResult>, so every existing await spawn(...) / spawn(...).then(...) caller is unchanged. What is new is that the same value is the live child: callers that want to supervise it (read .pid, .kill(signal), listen for exit) can, without a second spawn. @dbx-tools/appkit’s bindProcess consumes exactly this - one code path supervises both a bare ChildProcess (e.g. portr) and a spawn() result.

Await it (unchanged)
const { stdout } = await spawn("git", ["rev-parse", "HEAD"], { stdout: "capture" });
Supervise it
const proc = spawn("bun", ["src/server.ts"]);
ctx.bindProcess(proc); // live handle
const { exitCode } = await proc; // still a promise