summaryrefslogtreecommitdiff
path: root/fw/doc/design.md
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2026-08-19 10:00:34 -0400
committerCalvin Morrison <calvin@pobox.com>2026-08-19 10:00:34 -0400
commitdee31d66b705734be68c1bb21ff5dfc7bdaae23b (patch)
treea878c2b64b4106c02d4039f2c91c6b43ef548a01 /fw/doc/design.md
parent1575b83f102060eab99248c8e7660e9f61df1389 (diff)
fw: make the /srv name worth watching, and say how to supervise it
todo.md said fw daemonizing meant svc could not supervise it, and that it needed a foreground mode. Both wrong. svc has had the shape from the start. ready=srv: watches the /srv name rather than the pid, and its own manual says why: "Use this for a service that posts to /srv and lets the process you started exit, which many Plan 9 file servers do on purpose. For these the /srv file is watched and the process is not, so the process exiting is normal and never causes a restart." init.c agrees -- reap() returns early for Ksrv with that comment on it. Nor is detaching unusual. 42 commands under /sys/src/cmd use postmountsrv or threadpostmountsrv; five call srv() directly, and every one of those is a stdio server (ramfs -i, ext4srv -s, skelfs, hjfs, wacom) speaking 9P on file descriptors it was handed. That is not a foreground service, it is a pipe server: no /srv, no mount, nothing to supervise. A foreground mode for fw would buy a pid to watch, and the /srv name is the better signal -- it survives the process that made it. What was true underneath the wrong diagnosis: the name was not honest. Taking the control filesystem away ends the server proc, and the relays carried on filtering: procs: 3 ... take the ctl filesystem away ... procs after: 2 still filtering? pkt interface: pkt0 A firewall nobody can reach, stop, or notice, and the /srv name gone while it runs. Srv.end now takes the whole thing down, which is the answer the relays already gave when their wire failed. Same test after: three procs become none and the interface goes with them. So: no flag, an example service file in lib/svc, and a SUPERVISION section in fw(8) that says what init should watch and what restarting will and will not fix. Restart=always brings fw back; it does not undo taking the card, so the new fw has no address to read. Supervision works, recovery does not, and that stays open as item 1. Two checks. Against the previous fw.c they fail with two orphaned procs and a pkt interface still bound -- and so do the leak checks at the end of the run, which is what they were built for. 77 pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'fw/doc/design.md')
-rw-r--r--fw/doc/design.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/fw/doc/design.md b/fw/doc/design.md
index c14787c..1060ba6 100644
--- a/fw/doc/design.md
+++ b/fw/doc/design.md
@@ -143,6 +143,15 @@ forbid are dropped. pf and iptables leave them running until they time
out; that is a wart everyone has to learn, and "I blocked it, why is the
transfer still going" is the wrong thing to discover at 3am.
+**A file server, so it detaches.** `fw` posts to `/srv`, forks the
+server and lets the process you started exit — what 42 of the 47 file
+servers in `/sys/src/cmd` do, and the five that do not are stdio
+servers speaking 9P on their own standard input, which is a different
+thing altogether. So a supervisor watches the `/srv` name and not the
+pid, which `svc` already provides for. The name is only worth watching
+if it is honest, which is why anything that stops one part of `fw` now
+stops all of it.
+
**Per-rule logging to `/sys/log/fw`.** Global logging either floods a
disk or tells you nothing. `syslog(2)` does not create its file, so `fw`
says so at startup rather than dropping the lines silently.