An external, end to end
A command owns its preparation and start; a collector owns its running
child. Prepared in core/src/shell/exec/command.rs uses the process
layer in core/src/process/launch.rs. Lone commands and direct pipeline
stages share startup, pump setup, reaper registration and collection. Their
streams, placement and audit context differ. A detached command shares
preparation and failure interpretation, but returns no kept child. What the operation means
is exec; what a confined launch adds is
confined-launch.
Three stages
| stage | function | it does | its failures leave as |
|---|---|---|---|
| prepare | Command::prepare | reads the head’s verdict, vets argv and owns the launch, its image, interpreter and confinement context; detach alone asks for a surrendered one | the head’s verdict; a refused argument; a preparation error |
| start | Prepared::start / run, Prepared::detach | consumes the command, connects its streams (a survivor’s to null), and spawns under the scope; a kept result owns the child, opaque terminal hold, pumps and denial PIDs, a detached result is Survivor | Program::unstarted, the one conversion of Unstarted, below |
| ending | ending | a death by a signal of a cause in force is that cause’s stop; any other end is a process failure (Reason::process), with the kernel’s account of the deny lines its start claimed | a stop, or a process failure |
- Every failure of a stage has one home. Preparation raises its refusals as
the
Errors its building meets;unstartedis the only place a launch that returned no kept child becomes the run’s error;endingis the only place a child’s end does. A fourth way to raise is a defect. - Installation fixes child setup order once. A launch’s child steps are
data, its
ChildSetup, whatever order they were configured in; the spawn’sChildSetup::installregisters them as one hook: merge stderr, capture payload streams, apply session limits, then mandatory limits and confinement. Descriptor handoff precedes it; placement, signal reset and the exec-readiness marker follow it. The parent drops child-only descriptors right after the fork, before waiting for the payload report. - Building describes; starting acts (exec). Two things in
preparetouch the world: a guest jail’s cgroup, whichJailCgroup::dropremoves if the built launch is dropped, and Linux’s bwrap host probe, which waits on bwrap children once per process. Whatever may be stopped, Windows’ stamps and token and the wait for a trampoline’s first word, is the direct or enveloped spawn’s, under the scopestarthands it. On Unix the scope is read once, before the fork; on Windows before confining and again just before the child is made, so a wall that expired during minutes of stamping is found before the child exists. Sostartis the one place a launch is stopped or fails as a program. - Where a child ended is amended before
endingsees it (the-ending-is-amended-where-it-is-reaped).
How a start fails
Unstarted says whose failure it was, and the answer is never inferred from
an errno. Direct and enveloped spawns return the same failure type.
Which of the three cases a failure is, and so whom it blames, is
ral-s-failure-is-never-the-programs.
Stopped arises from Launch::born’s poll, dacl::cancelled and
Testimony::first.
Programis read as the program’s.Program::exec_errorturns it into the same process failure the probe reports, with the interpreter hint where it applies.Refusedpreserves a typed launch cause: the failed preparation step, launcher or confinement operation, with I/O evidence where applicable. Its description is derived without blaming the program.- The mark decides it: a spawn error that the child’s last pre-exec step
did not precede is ral’s
(no-mark-ral-s-fault).
SpawnErrorisPrepare,SetuporExec, andforkreads it:Setupretains its typed launch failure;Prepareuses recorded setup evidence when available, otherwise a typed launcher failure. Both are ral’s own, whatever stands in the program’s place.ExecisProgram, unless the launch holds aLauncher: then it is that launcher’s, andRefused. Only the fork is read so. A payload report’sProgram(errno)is heard afterwards and is never rewritten as a launcher refusal. - A discarded child is killed and reaped (
Unlanded). A refusal after the fork, such as an unnameable payload group or a refused report, leaves no running child behind.bornholds the created child in anUnlanded, names an envelope’s payload group into it before it hears anything, and retains the appliedStepand request until landing completes. Unless the child lands, the guard’s drop kills the payload’s group, then the child’s own fresh group whenStep::leads(), before reaping the child, whose unreaped pid pins the group it leads: no exit from a birth skips it.bornthen drops the request, restoring captured state, and releases the jail.detachleaves its survivor: it is never killed. - A refused terminal handoff may follow effects.
Launch::spawnlends a direct tenant’s fresh group after exec. Refusal retains the captured guard through group kill and child kill/reap, then restores state and releases the jail before returningUnstarted::Refused, naming the operation and OS error. It does not claim the command never ran. - A failed start owns its drains until caller settlement.
Prepared::startreturnsStartFailurewith the reason and already-started drains: even a refused child may have written output. A lonerunsettles before propagating the reason. A pipeline first rolls back and joins its owner, even if no stage registered, then settles the failed-start drains before returning the error. A joined child’s descendants are its enclosing owner’s to kill, not the failed launch’s.StartFailure::settleuses an empty kill callback, never a numeric ID retained after reap.Drains::dropremains non-blocking for unwinding.
Which failure reads as what
The spawn’s errno says what the OS found; the image says what that means.
Program::exec_error reads it against the Image the launch was built from, and
names where the program was found as lookup named it: the path as typed, or
the one a PATH search built.
ENOENTfor an image that still exists on the host isnot-runnable ... missing-interpreter. The file is there; what it needs is not. The failure names the#!interpreter read with the image (interpreter_of, kept in thePreparedlaunch’sProgram), never what the file says by the time the kernel refused. A bundled tool, or a file gone from its real path, isnot-found.- Only a permission refusal is
permission-denied.EACCESat the spawn, or a walk, a path head’s or aPATHcandidate’s, that fails by a refusal. Any other walk error retains its typedIoCause, including foreign OS detail where needed; absence and a non-directory component arenot-found. - A confined
EACCESorENOENTwhose interpreter the launch’s own projection hides ispermission-deniedplus the interpreter hint, on both platforms: Seatbelt refuses the exec (EACCES), bwrap hides the interpreter (ENOENT), and the user sees one thing.Preparedkeeps the launch’s own confinement, and only on a failure to start is the verdict asked of it (interpreter_hint): the exec table’s, then the read table’s, so an interpreter excluded, not admitted to run, or outside the read set each names its fix; with no projection, as inside the guest jail, there is no verdict and so no hint, and a hidden interpreter reads as missing. - The path-as-text hint is one rule, at the machine’s
dispatch_exec(offer_path_as_text). It is offered only to a path head given no arguments, most likely meant as text, to a refused admission and to a run that named a directory or plain file, never to another failure. It is a stored hint like any other, composed asdocs/SPEC.md§13.1 says.
The trampoline reports
A confined launch’s trampoline testifies on a report socket; the parent hears the first word before it believes the program started. The records, the socket’s discipline and why they hold are a-launchs-report-is-the-trampolines-alone.
- The first word.
Testimony::firstreturns once the program runs. On macOS the trampolineexecves in place, so its close-on-exec writer closing is the start, and EOF before a record says so. On Linux the trampoline supervises, so EOF before a record is an envelope that died:Refused. - The wait is a cancellable one (a-first-word-is-waited-for-under-the-scope): a stop ends it, and the child is discarded.
- The parent’s writer copy outlives the hook that names it.
Handoff::keeplends the child a copy of the report’s writer at a fixed number and the spawn’spre_execclears close-on-exec on that number, so the parent keeps the copy open until the fork andReport::forkeddrops it right after. ALaunchis spent by its spawn (spawntakesself), since a second spawn would hear a first one’s launcher end and read it as the program’s. - What remains of the report on Linux rides the
ChildHandleas itsTestimony, read at the reaper (the-ending-is-amended-where-it-is-reaped). The supervisor that writes it is the-trampoline-is-a-supervisor.
Whose deny lines a failure owns
A failure owns only the kernel deny lines its start claimed. start takes
its denial_pids the moment the spawn returns, and ending hands exit_error the
Failure itself, never its rendering.
- Confinement is preparation’s fact: a projection, or the guest jail. An unconfined child claims nothing, so its failure reads no log.
- A line carries only the host pid the kernel denied: Seatbelt’s
comm(pid), and seccomp’s auditpid=, which is the host’s number even inside a pid namespace. So a claim is a set of pids, each read while its process lived.- A direct child (macOS, which
execves in place; the guest jail) claims its own pid, which is the program’s. - An enveloped child (Linux) claims the chain beneath its payload’s group
leader: the namespace’s init, the supervisor, the program. bwrap’s
monitor is confined by nothing, and no process inside the namespace can
name the program’s host pid, so
payload_pidsreads the chain from the host’s/proc/<pid>/task/*/childrenright after the trampoline has saidstarted, the one moment the program is known to run.
- A direct child (macOS, which
- What a claim misses. A process gone before its claim was read (a program
that dies within microseconds of starting) or born after it (every later
descendant, such as
sh -c 'cat x'’scat) is not claimed, and its line is not shown. - A line is never claimed falsely. Each pid was read alive, so a line names it only if that very process was denied, short of the host reusing the pid within the window, which takes a wrap of its whole pid space.
- No sample is taken after the end. A process’s children are reparented when it exits, not when it is reaped, and an envelope’s namespace is dead before bwrap exits: such a sample finds nothing of the command, and one of ral’s own live tree would claim a stranger’s line.
- The hint is decided from the datum: the claimed lines first; else, on
macOS, an
Exited(128)gets the fork brake’s conditional explanation. A death by a signal is never read as a status.
Where the child landed
A child’s Group is computed once, at its birth, and carried.
Shell::group_owner gathers stage membership or session facts once;
Placement::command selects Join, permitted Tenant, interactive Inherit
or headless NewSession. Placement::input determines the requested terminal
stdin before Source::offered interprets it. Placement::land derives every
ordinary direct Group from that request, after the platform has applied its
Step; platform code builds no group. Linux’s EnvelopedLaunch::spawn calls
born with Step::NewLeader and lands on Group::Enveloped, the payload’s
group; Confinement::denial_pids reads payload_pids from it. An eligible
envelope’s Tenant keeps readable
stdin and a restoration-only hold, without handoff or key attribution.
Otherwise the direct tenant’s landing mints a Leader and lends to &Leader.
The certificate proves fresh-group birth in ral’s session, not liveness;
spawn_leader returns the same certificate to the anchor beside its child pin.
Spawned<G> varies only its group field. Spawned.terminal carries the opaque
hold to collection, which reclaims it before jail settlement and pump joins.
Nothing downstream recomputes the landing (a-child-lands-once);
what each landing lets a collector signal is
a-process-group-is-its-owners-to-signal’s. The process limit is a
property of the launch, applied where the child is born (a macOS fork limit set
in pre_exec; on Windows the Job Object’s, before the child resumes; Linux
sets none), so a child never runs without the budget its grant states
(a-process-limit-binds-before-the-child-runs).
See also exec, failure, exec-judgment, confined-launch, cancellation, io-process.