1.8 KiB
1.8 KiB
description
| description |
|---|
| Child processes use plain node:child_process spawn (explicit stdio, uid/gid, whole env); src/child.ts has exitCode (128+signo) and echo; no execFile maxBuffer |
Every call site calls spawn from node:child_process itself, with
everything explicit:
uid/gidof the profile for anything an agent profile runs (each profile is its own UID, 20000+). Never drop them.envis the whole environment the child gets (a sanitized one for agents); nothing from the coordinator is merged in.stdio: stdin is"ignore"so an agent CLI never waits on input (onlycodex login --with-api-keypipes the token in). Output that is not read is"ignore"; output that is read is"pipe"and streamed.- No
execFile/exec: theirmaxBuffer(1 MiB) kills a chatty child. Read piped streams incrementally instead.
src/child.ts holds what the call sites share:
exitCode(child): call it right afterspawn. It settles onexit(notclose, which a daemonized grandchild can hold open), maps a signal to128 + signoas a shell does, and rejects on a failed start. The rejection is pre-caught so it is not reported as unhandled before the caller awaits it.echo(stream, chunk): writes and waits fordrainwhen the buffer is full, so echoing never outruns a slow reader.
Tests use spawnSync for short commands.
Other port details:
src/errors.tsisNotFoundchecksENOENT(file) orESRCH(process).- Temporary files are an exclusive
wxcreate with mode0600. src/json.tsholds type guards used instead ofascasts on parsed JSON.processandBuffermust come fromnode:imports:no-restricted-globalsinscripts/project-lint.tsenforces it (lint-parity-never-shrinks).
Related: how each agent CLI reports bad credentials is in agent-cli-auth-failures.