roadmap BUILT

48. Job control: jobs, wait, kill, fg, bg, and a stopped state

BUILT, 2026-10-18 (UTC). For supervised jobs, a trailing &, jobs, wait, kill, fg, bg and Ctrl-Z work at a real prompt, proved by script/swish-check on all three architectures. §300 (the paused state) gives the kernel ThreadControlBlock::SUSPEND and RESUME: they ride the TCB capability, resume continues at the PC, and §26 (the fault endpoint) carries no stopped event. §309 (a supervised job's ThreadControlBlock goes to the shell that asked for it) puts that capability in the shell's hands.

Why it matters. Unix job control is one of the most intricate things in a kernel: sessions, a controlling terminal, process groups, tcsetpgrp, and SIGTSTP/SIGCONT/SIGTTIN/SIGTTOU. Most of that machinery exists to answer one question (who may read the keyboard), and here that question answers itself.

A job is what the shell holds capabilities for

Structural rather than conventional. Unix's process group is a number with inherited, mutable membership; "what I hold" cannot drift. What the shell holds depends on how the job was built:

So phase one covers supervised jobs, and & on any other program is refused with a sentence.

Phase one: built, for supervised jobs

Foreground versus background is not a capability transfer, and the reason is in the tree: no spawned program holds terminal input. The progenitor grants a child the terminal's sink, which writes, and never the line discipline's READLINE. So fg has nothing to revoke. A foreground job is one the shell is watching, with the terminal out of raw mode so its line discipline counts ^C; at the prompt a ^C is a byte to the line editor and reaches no background job. A background job that wanted to read the terminal would find no capability to read with.

The swish-check lines are in xtask/src/swish_check/script/interrupts.rs. The parsing is host-tested in grant_plan (job_operand, kill_operands) and swish::sequence.

BUGS

Phase two: the stopped state

Only Ctrl-Z, bg on a stopped job, and zsh's suspend need pausing a thread resumably. §24's tiers are notify and kill, with pause deliberately absent. §300 adds SUSPEND and RESUME, silent, designed for all three of §24's triggers (job control, a userspace pager, and a debugger) rather than for job control alone. notes/suspend-and-resume.md has the kernel's cases.

BUGS

Follow-on

The open question: disown

If the shell drops its capabilities to a job, nobody can reap it, and §26's dead-until-reaped means the corpse persists. Unix reparents orphans to init and lets init reap them; here reparenting means transferring the supervision endpoint, which is an explicit act rather than a rule nobody thinks about. Decided as DECISIONS §40: a supervisor's death is its subtree's death, because a child's resources come from its supervisor's region and §16's revocation reclaims the whole subtree in one act. So disown means transfer supervision upward, not "abandon". §40 (a supervisor's death is its subtree's death) records the hole that makes the cascade close to the only coherent answer. §32 (a supervisor may collect a corpse) authorizes reaping by matching the child's recorded fault_ep, which nobody can satisfy once the supervisor's endpoint is gone.

Index row

most of it needs no new kernel surface, and the tty's most tangled feature turns out to be a capability transfer