docs(rfc): propose ending a confined worker's programs with it

Merged
KI
1mo ago
+176-0

Problem

A confined worker leads its own session, so programs it starts share its process group. None of them end with it:

  • When the worker exits, a program it left running keeps its --direct paths, the runtime directories, the network, and the terminal.
  • When the broker gets SIGINT, SIGTERM, or SIGHUP, the worker dies by its death signal, but programs it started have none and outlive both. broker_confined.rs::kernel::a_program_a_confined_worker_starts_outlives_its_broker shows this.

Change

RFC 0010 proposes that in confined mode the broker kills the worker's process group:

  • When the worker exits: waitid(WNOWAIT), then kill(-pid, SIGKILL), then reap. The zombie keeps the ID in use, so the kill can't reach a reused ID.
  • On SIGINT, SIGTERM, or SIGHUP: a thread blocked in sigwait kills the group, the main thread reaps the worker, and the broker dies by the same signal.

--unconfined is unchanged, because that worker shares the broker's group. The RFC documents the limits: programs that call setsid or setpgid, and SIGKILL to the broker. It weighs PID namespaces, cgroup.kill, a child subreaper, and signal-hook as alternatives.

This follows the maintainer's choice, among the options from the internal review, to kill the process group. The RFC asks two questions:

  1. Should signals go through sigwait in the existing sys module, or through signal-hook?
  2. When stopped, should the broker die by the signal, or exit with 128 plus its number?

It also adds the roadmap item under M9.

Verification

Docs only. Checked against the code:

  • confine.rs calls setsid before the death signal.
  • fsgate-broker.rs::run_inherited reaps with Child::wait.
  • rustix 1.1.6 has safe waitid with WaitIdOptions::NOWAIT and kill_process_group, and only unsafe signal-mask calls.

Nothing was implemented or run.

Documentation and release

No behavior change and no changelog entry. If accepted, the implementation updates the threat model's lifetime rows, the README limit, RFC 0008's "does not stop" list, and the changelog under Changed.

Decisions

The maintainer accepted the RFC as written, and the second commit records it. Signals use sigwait in the sys module of confine.rs, with no new dependency, and a broker stopped by a signal dies by that signal. The roadmap marks the RFC item done and adds "Implement RFC 0010".