Skip to content

Reload the supervised sender by its own handle, not by name - #55

Merged
pjeweb merged 7 commits into
osb/base/merged-20261114.1from
osb/pr/sender-signal-by-pid
Nov 14, 2026
Merged

pjeweb merged 7 commits into
osb/base/merged-20261114.1from
osb/pr/sender-signal-by-pid

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 13, 2026 •

Copy link
Copy Markdown

Why

When the bond changes during a stream, the backend tells the sender to reload with killall -HUP srtla_send. That signal reaches every process with that name on the box, not just the sender this backend started: a second sender, a diagnostic run, or later a sender that should keep running across a backend restart. A reload should only reach the sender the backend owns.

What it adds

  • A bond change now reloads only the sender the backend started and still tracks. Any other srtla_send on the box is left alone.
  • If a reload reached no sender, the backend logs a warning instead of passing over it silently.
  • With a single sender, the signal, its target and its timing stay the same as before. A custom killall_binary setting no longer affects the reload.

How

The backend's process runner already keeps a handle (its own reference) to each process it starts. A new signalSenders(signal) sends the signal through those handles, skips senders that have already exited, and returns how many received it. restartSrtla() uses it and reports whether at least one sender was reached. The startup sweep that clears leftover senders at boot still works by name; replacing it is left for a separate change.

Stacked on #54 (test process isolation) at 50e8182ecdd5ac01f21c13d61756c4c954659f9c.

Technical detail
  • signalSenders(signal) in the process runner signals every live sender process the backend spawned and tracks, using its own process handle, and returns how many received it. A handle whose process has already exited is skipped (Bun's kill on an exited child is a silent no-op, so the exit state is checked first).
  • restartSrtla() uses it and returns whether at least one supervised sender received the SIGHUP. If none did, it logs a warning.
  • The call site in the streaming session is unchanged.

With a single sender, the signal, its target process and its timing stay the same as before. The intended differences are that a foreign srtla_send is no longer signalled, a custom killall_binary setting no longer affects the reload, and a reload that reached no sender is now visible instead of passing silently.

Stacked on #54 at 50e8182ecdd5ac01f21c13d61756c4c954659f9c, including the stricter process/network guards and the development-backend boot fix. The sender reload change is unchanged by the rebase. The startup orphan sweep (killall srtla_send at boot) is deliberately unchanged here. Replacing it needs ownership checks (recorded PID plus start time, or the service's own cgroup) and a decision on whether a name-only fallback should remain, so it is left for a separate change.

Review fixes

Restacked onto #54's ownership and redirect fixes. The sender reload implementation is unchanged; range comparison matches the previous incremental commit exactly.

Current validation on Bun 1.4.4, one worker, transient units with UMask 0022, Nice 10, CPUWeight 50, C.UTF-8 and PID isolation: backend 12,688 pass / 19 skip / 0 fail across 1,103 files; safety and sender-reload tests 32 pass; safety with the foreign parent's proc entry hidden 27 pass. Lint/types and debt pass. The real development backend remains alive and accepts connections after 45 seconds under the safety preload, with no guard violations. The frontend and guard sources are identical to #54, whose serial Node 24 frontend run passed 7,650 tests across 459 files; shared RPC 827, i18n 797, sender 123 and hardware preflight 4 also pass there. Browser E2E was not rerun for this restack.

Tests and validation

New sender-reload-by-pid.test.ts, written before the change. It spawns two copies of a small shell script named srtla_send that records each SIGHUP it receives: one through the process runner (tracked) and one directly (untracked). Nothing is signalled by name.

  • A reload signals the tracked copy exactly once. The untracked copy receives nothing and stays alive. No name signal is issued.
  • With no supervised sender, or after the tracked sender has exited, the reload returns false.
  • signalSenders skips non-sender and exited processes, and counts a throwing kill as not delivered.

Before the change, the three reload tests failed. After it, the full backend suite passes (12,662 pass, 19 skip, 0 fail across 1,101 files, four workers, inside a PID namespace). Root lint, backend/shared/frontend type checks, the exec guard and the tech-debt check also pass. The frontend has no code changes.

Your call

The test spawn guard listed the systemctl actions it refused, so verbs
such as daemon-reload or try-reload-or-restart passed. It now accepts only
known read-only verbs (show, status, is-active, list-units and similar).
The process guard now covers Bun.$, env -S, xargs, busybox and find -exec
wrappers, positional sh -c forms, symlinks judged by their target, and
shell scripts that signal by absolute path. process.kill reaches only the
test process and processes it spawned. A PATH directory of recording stubs
backs this up for by-name calls from scripts and other interpreters.

The network guard now applies to backend unit tests too and covers
Bun.connect, dgram, Bun.udpSocket and DNS. Client ws sockets open through
one helper that calls the guard. Under mocks the remote client stays idle
unless its endpoint is loopback, and name signals follow the mock gate
plus a development-harness marker.
On a host without systemctl the PATH stub recorded read-only queries such
as `systemctl is-enabled ssh` as violations; they now exit 127 like a
missing binary. The SSH status probes live in a leaf module whose test
seam the unit preload sets, so status builders never ask the host about
its ssh unit and the preload loads no SSH dependency graph.

The guard now covers process._kill, refuses Worker threads (where it does
not run), reads shell scripts run by path or shebang (name-based signals
refused, builtin kill limited to owned PIDs), follows su/runuser/script/sg
command strings and chroot, and judges a proxied fetch by its proxy. The
network guard stands down only in a marked private network namespace, not
in any loopback-only one. Scans keep backend source off Bun.fetch and off
dynamic or re-exported ws imports.
The development harness refuses DNS since the previous change, and the
dev backend exited at boot: uplink health resolved the public check domain
(and DNS validation its well-known name) on the host every round, then
probed through mock interface names. Under mocks there is no real uplink,
so the default target resolver now returns none and the active round is
skipped, exactly as for an unresolvable address.
@pjeweb
pjeweb force-pushed the osb/pr/sender-signal-by-pid branch from c1a5b0b to 61989a2 Compare November 13, 2026 11:40
@pjeweb
pjeweb added this pull request to stack #62 November 13, 2026 11:48
The bond reload sent SIGHUP to every process named srtla_send. A second
sender, a diagnostic run or a sender that should survive a backend restart
received the same signal. The reload now signals the live sender processes
the backend spawned and tracks, and reports whether any of them received it.

With one sender the signal, its target and its timing are unchanged. A
foreign process with the same name is no longer signalled, and a reload that
reached no supervised sender is logged instead of passing silently.

The startup orphan sweep still signals by name; changing it needs ownership
checks and is left for a separate change.
@pjeweb
pjeweb force-pushed the osb/pr/sender-signal-by-pid branch from 61989a2 to 5e35682 Compare November 13, 2026 19:30
@pjeweb
pjeweb removed this pull request from stack #62 November 14, 2026 07:45
@pjeweb
pjeweb changed the base branch from osb/pr/test-process-isolation to osb/base/merged-20261114.1 November 14, 2026 07:45
@pjeweb
pjeweb merged commit 2f46bc1 into osb/base/merged-20261114.1 Nov 14, 2026
3 checks passed
@pjeweb pjeweb added upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal. stacked Depends on another pull request; review and integrate parents first. labels Nov 16, 2026
@pjeweb

pjeweb commented Nov 25, 2026

Copy link
Copy Markdown
Author

Still carried in the integration train and not upstream, so it continues as #236.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stacked Depends on another pull request; review and integrate parents first. upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal.

Development

Successfully merging this pull request may close these issues.

1 participant