child_process
child_process runs OS subprocesses. POSIX only (macOS and Linux), max 8
concurrent children. Everything is evented on the main loop — no extra
threads — and it is safe to use alongside http.serve, fetch, or Worker.
Quick look
Reference
Options (all functions): cwd (string), env (object — replaces the
environment), maxBuffer (bytes per stream, default 1 MB, Infinity
allowed). spawn additionally takes stdio: "pipe" | "inherit" (default
"pipe"; "inherit" passes ff's stdio through and captures nothing).
The Child object
For spawn, the returned object exposes the captured results:
spawn results land on the object at the same moment wait() resolves:
Examples
Capture output and check the exit code:
Run without a shell (no quoting worries):
Stop a long-running child:
Synchronous use in scripts:
Caveats
- No streams or events. There is no
child.stdin, noon("data"), and nospawnSyncin this version — output is captured and delivered throughwait()/ the returned promise. Writing to stdin is not supported yet. - A running child keeps ff alive — the process won't exit until its
children are reaped (let them finish, or
kill()them).process.exit()bypasses this. - Children are not killed when ff exits — same as Node. Call
kill()yourself for anything that must not outlive the runtime. wait()waits for the pipes to close, so a grandchild that inheritsstdout/stderrdelays resolution (Node'scloseevent behaves the same).execoutput is decoded as UTF-8; binary output may not round-trip.process.stats().childexposesspawned/truncated/outHeapcounters for watching subprocess activity.
