Relationships
#4797 serve --exit-on-stdin-close: a serve drains and exits when its stdin closes
Opened by zack · 11/16/2026· Shipped 11/16/2026
Issue 3 of 18 in the execution plan of design/surfaces/serve-workspaces.md. One PR. No dependencies.
Problem
swamp serve host will start one swamp serve child per workspace. If the host is killed outright, its children must not keep running: each one holds a port and its repo's writer lease, and nothing would be left to route to it.
A child cannot rely on a signal for this. A host that dies from SIGKILL sends none, and Windows has no equivalent of a parent-death signal. A pipe does work everywhere: the host holds the write end of each child's stdin, and the operating system closes it when the host exits for any reason.
Change
Add a hidden flag --exit-on-stdin-close to swamp serve (src/cli/commands/serve.ts).
- With the flag, end of file on stdin starts the same drain that SIGTERM starts.
- Without the flag, serve does not read its stdin. Nothing changes for a serve run from a terminal, a service manager or a container.
The flag is hidden because only the host passes it.
Done when
- A serve started with the flag whose stdin closes drains and exits 0.
- A serve started without the flag ignores its stdin, open or closed.
- The drain is the one SIGTERM starts:
/readyreports 503 and in-flight runs get the configured grace period. - The shutdown trigger is tested in-process with a fake stdin. A journey that spawns the binary belongs in
swamp-uat.
Out of scope
The supervisor that holds the pipe. That is issue 5 in the plan.
Shipped
Click a lifecycle step above to view its details.
Sign in to post a ripple.