diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-27 15:32:02 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-27 16:12:35 -0300 |
| commit | 5f4719da21f06b58694d52d354f5fda431ff8543 (patch) | |
| tree | eadd147cd18c53637f2287a3ed9e62fe1187280d /src/detached | |
| parent | 0a21ea831d6791b406eef70b3e95cfd319d8ed36 (diff) | |
| download | pardes-5f4719da21f06b58694d52d354f5fda431ff8543.tar.gz pardes-5f4719da21f06b58694d52d354f5fda431ff8543.zip | |
acmefs: a pane's terminal gets pty/data, pty/ctl and pty/status
Step 3 of the 9P chain (docs/9p.typ 12.3, docs/registry.typ 9P-8). Nothing here
is about 9P: it lands in the FUSE-served tree and any later transport inherits it.
A script could write into a terminal that already existed and read its rendered
scrollback. It could not START one, RESIZE one or SIGNAL one. Two of those were
already effects the core emits, so `exec` and `winsize` are existing
capabilities acquiring a name; only `sig` is new, and it brings the one new
host method, `push_pty_signal`.
pty/ctl winsize <cols> <rows> | sig INT|TERM|HUP|QUIT|KILL | exec
one verb per line, validate-all then apply-all, EINVAL applies
nothing -- `writeCtl`'s shape and `writeCtl`'s reason
pty/status cols, rows, tty-taken as three %11d fields
pty/data write is input to the process; read is the RAW output stream,
gated on a reader count so a pane nobody reads costs one branch
A pane that is not a terminal has no pty/ at all: the lookup is ENOENT and
readdir does not list it.
`PaneFile` is an enum(u4) and this takes it from 11 values to 15. ONE REMAINS.
That is also why pty/ is a DIRECTORY and not three more flat names -- a
subdirectory costs one value and buys its own namespace, so `ctl` and `data`
did not have to be renamed.
Two things the core does not know, and which are therefore not invented: a
child's EXIT STATUS (a shell's death is `Event.eof`, which removes the pane,
so there is no directory left to read it in) and RAW/COOKED (the core never
sets a termios; the mode belongs to the program on the far side).
Verified live against a daemon: pty/ appears only on the terminal pane; a
`winsize 0 24` and a `sig SIGINT` are refused; a bad verb beside a good one
applies neither; `echo pty-works` written to pty/data runs in the shell and its
output reaches the body; and a blocking read of pty/data returns the raw stream,
OSC 133 marks and all. fs-bench unchanged and still zero allocations.
Diffstat (limited to 'src/detached')
| -rw-r--r-- | src/detached/server.zig | 21 | ||||
| -rw-r--r-- | src/detached/wire.zig | 20 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/detached/server.zig b/src/detached/server.zig index 9a8dc24f..d8373149 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -590,14 +590,14 @@ pub const Session = struct { return @ptrCast(@alignCast(ctx.?)); } - /// Seventeen methods, and NOT the fullest host in the tree — that claim + /// Eighteen methods, and NOT the fullest host in the tree — that claim /// stood here, was believed, and was copied into docs/detached.md before an - /// audit counted the others. The tty and SDL shells fill NINETEEN each - /// (everything but `pull_gpio_toggle` and `push_detach`) and macOS fourteen, + /// audit counted the others. The tty and SDL shells fill TWENTY each + /// (everything but `pull_gpio_toggle` and `push_detach`) and macOS fifteen, /// so this host is the only one that implements `push_detach` and otherwise /// the least complete of the three desktop hosts. What is true is narrower /// and is the point anyway: it performs every MACHINE-LOCAL effect there is, - /// and the four of host.zig's twenty-one it leaves null are null because + /// and the four of host.zig's twenty-two it leaves null are null because /// there is nothing here for them to do. Two of those four are real losses a /// person can notice — no `pull_lsp` and no `pull_pipe`, because both want /// the worker pool this deliberately single-threaded loop does not have. The @@ -619,6 +619,7 @@ pub const Session = struct { .push_spawn = spawn, .push_pty_write = ptyWrite, .push_pty_resize = ptyResize, + .push_pty_signal = ptySignal, .pull_tty_taken = ttyTaken, .push_write_file = writeFile, .push_write_dump = writeDump, @@ -771,6 +772,18 @@ pub const Session = struct { _ = posix.system.ioctl(fd, TIOCSWINSZ, @intFromPtr(&ws)); } + /// `pty/ctl`'s `sig` — and the host where it matters most, because these + /// shells outlive every frontend: a script that signals a build in a + /// detached session is signalling a process nobody has a terminal on. + /// `fd < 0` is a pane with no shell, the same silence `ptyWrite` gives it. + fn ptySignal(ctx: ?*anyopaque, pane: u8, sig: pardes.PtySignal) void { + const s = of(ctx); + if (pane >= s.ptys.len) return; + const pt = s.ptys[pane]; + if (pt.fd < 0) return; + look.signalTty(pt.pid, pt.fd, sig); + } + /// Is this pane's tty still the prompt we forked, or has a program taken it? /// /// Answerable at all only because the pty is HERE. While a pane's shell diff --git a/src/detached/wire.zig b/src/detached/wire.zig index a84c2a68..23a85158 100644 --- a/src/detached/wire.zig +++ b/src/detached/wire.zig @@ -39,16 +39,18 @@ //! frontend must not have to have been built with the core's options — so it is //! ALWAYS on the wire and dropped on arrival by a build with nowhere to put it. //! -//! WHAT IS NOT HERE. The seam has twenty-one methods; this carries FIVE of +//! WHAT IS NOT HERE. The seam has twenty-two methods; this carries FIVE of //! them — `push_present` as `frame`, `push_set_clipboard`, -//! `pull_read_clipboard`, `push_open_link` and `push_detach` — and the sixteen -//! it does not are named here with their reasons. The five are spelled out -//! because this arithmetic has now gone stale twice in one day, once when the -//! machine-local eight moved into the daemon and once when `detach` arrived, -//! and a count nobody can check against a list is a comment that rots quietly. -//! * The eight machine-local ones — `push_spawn`, `push_pty_write`, -//! `push_pty_resize`, `push_write_file`, `push_write_dump`, -//! `push_watch_file`, `push_watch_theme`, `push_dump_themes` — are +//! `pull_read_clipboard`, `push_open_link` and `push_detach` — and the +//! seventeen it does not are named here with their reasons. The five are +//! spelled out because this arithmetic has now gone stale twice in one day, +//! once when the machine-local eight moved into the daemon and once when +//! `detach` arrived, and a count nobody can check against a list is a comment +//! that rots quietly. +//! * The nine machine-local ones — `push_spawn`, `push_pty_write`, +//! `push_pty_resize`, `push_pty_signal`, `push_write_file`, +//! `push_write_dump`, `push_watch_file`, `push_watch_theme`, +//! `push_dump_themes` — are //! performed by the detached core ITSELF, through `host_io.zig`. A unix //! socket means it is on the same machine, so there is no question of //! whose disk or whose process table is meant, and a pane's shell has to |
