Stream frames of a process¶
This page gives the id-less stream frames that the daemon sends for a process: the stdout, stderr and exit frames, their seq numbers and the replay buffer. A process survives the disconnect of the connection that spawned it, and another connection picks it up with reattach.
An untagged rule on this page matches build 5fd08069 or an earlier build.
Stream notifications¶
A process.* client supplies its own id, which is any string. The daemon
delivers output as id-less stream notifications, and it buffers them for a
later replay.
{"type":"stream","processId":"<id>","stream":"stdout","seq":1,"data":"<base64>"}
{"type":"stream","processId":"<id>","stream":"stderr","seq":2,"data":"<base64>"}
{"type":"stream","processId":"<id>","stream":"exit","seq":3,"exitCode":0}
{"type":"stream","processId":"<id>","stream":"exit","seq":3,"exitCode":-1,"signal":"SIGTERM","killedBy":"client"}
seqis per-process. It starts at 1 and is monotonic across stdout/stderr/exit.datais base64 for stdout/stderr. Theexitframe carriesexitCodeand nodata. A signal-terminated child reportsexitCode: -1, not128+signo.signalandkilledByappear on theexitframe only, both afterexitCode, and both are omitempty, so a normal exit stays byte-identical.signalis the SIG-prefixed name of the terminating signal, such asSIGTERMorSIGKILL. It is omitted always on Windows (measured on Windows).killedBynames who asked the daemon to kill the process:clientforprocess.killandprocess.killAndWait,shutdownfor the shutdown andKillAllsweep,limitfor gitRead, andtemp_rootfor a lost private temp folder (4c111e86), andunattendedfor the unattended ends of a link-bound process and of a top-levelunattendedSeconds. It is emitted on every OS. A refused signal sets none (52d82f0a, Linux and macOS). Signal names other thanSIGTERMandSIGKILLare not measured. The shutdown sweep setsshutdownonly on aprocess.killAndWaitthat still waits. Linux measured it in the log. A latertemp_rootend replacesclient(4c111e86, macOS). Another kill keepsclient(not measured).- The
exitframe waits at most 5 seconds after the process exits for stdout/stderr to reach EOF. The daemon then closes the read ends and emits the frame anyway. This matters when a grandchild holds the same pipe, asnpm run dev &does. Output that the grandchild writes after the cap is lost, because that write failsEPIPE. - Inside that drain window
process.reattachreportsrunning: false. claustrum flips it at the reap. The reference is measuredfalseone second into the drain. - Inside the same window
process.stdinanswers-32602 Process not runningfor a write that carries fresh bytes, soappliedandstdinApplieddo not count bytes that the closed pipe discarded. An offset gap still answers-32003, and a wholly duplicate write still answers{"success":true,…,"duplicate":true}. The acknowledgement caveat ofstdinApplied(see process.reattach) still applies to a write accepted while the process was live.
Frame size and the replay buffer¶
- Each stdout/stderr frame carries at most one 32 KiB read. Larger output splits
across frames. Concatenate
datainseqorder to reassemble it. The exact frame boundaries depend on pipe scheduling and are not stable. Only the reassembled bytes are stable. - The replay buffer has a bound of 16 MiB per process. The daemon counts the
serialized frame including its trailing newline, which is the bytes a subscriber
receives, not the base64
dataalone. An exit frame therefore costs its envelope although it carries nodata. The daemon drops frames oldest-first, whole frames at a time, once adding a new frame pushes the buffer total over the cap. It always retains at least one frame, even a frame larger than the cap.reattach{fromSeq:0}therefore replays everything still retained, and not necessarily everything ever emitted.firstSeqis the floor. Compare it against the lastseqyou saw to detect a gap. - A process survives the disconnect of the connection that spawned it. Another
connection picks it up with
reattach. This is the multi-attach and reconnect mechanism.