diff options
Diffstat (limited to 'docs/typ/building.typ')
| -rw-r--r-- | docs/typ/building.typ | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ index d551c251..152be838 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -1,6 +1,6 @@ // Building pardes, for contributors: platforms, options, tests, the // release gates and sending patches, then how the pieces fit: the core -// and its shells, the threads, detached sessions, the 9P engine, the +// and its shells, the threads, the daemon and its sessions, the 9P engine, the // listeners and mounts. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs @@ -177,8 +177,9 @@ Code map: `src/panes.zig` and the pane kinds it names (`src/File.zig`, `src/Terminal.zig`, ...), `src/layout.zig`, `src/fs.zig` (host access, mounts and resolution) and `src/pardes.zig` (input), with one file per thing beside them (`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, -`mouse.zig`, ...). `src/ninep/` is the control tree, `src/detached/` the -wire, the detached core and the frontend client, `src/lsp/` the +`mouse.zig`, ...). `src/ninep/` is the control tree, `src/daemon.zig` the +per-user daemon and a terminal's stub, `src/detached/wire.zig` the input +wire a remote client will speak, `src/lsp/` the language-server client; `test/` holds harnesses, goldens and helix cases, `build/` the snapshot suite's build step. @@ -197,26 +198,34 @@ reading the live core, and a request id, the pane's serial and (for an edit) the file's revision reject a stale reply. A process that never calls `turn.start` (the tests, the ESP32-P4, the browser) has no second thread. -== Detached sessions +== The daemon and detached sessions -One poll loop in `src/detached/server.zig` owns core mutation, frontend -connections, pty I/O and file watches. The frontend socket is -`pardes-detached-<name>.sock` beside the session's 9P socket; a second -session cannot take a live name. Up to 32 frontends attach; frames go to -every one, while clipboard reads, browser opens and #word("Detach") go to -the frontend that asked (else the first attached). Frames are full grids -or changes against what each frontend last received, never queued: a -frontend with unsent bytes skips that frame, and one that stops draining -past 1 MiB of control backlog is closed, its peers untouched. Frontends -never spawn shells, write session files or watch files. #word("Attach") -connects first and swaps second: only after the handshake does a shell -give up its own core. #word("Restore") builds the replacement core before touching -the current one. +One `pardes --daemon` per user (`src/daemon.zig`) listens on +`pardes-daemon.sock` in the runtime directory, its `.lock` flocked for its +life; the first session that finds none starts it (a double fork and an +exec) and it exits a second after it holds nothing. It is nobody's parent: +a session registers on one connection, sends it a dup of every pty master +it forks (so a session killed outright never hangs its shells up, and +#word("Adopt") takes them into another), says whether a terminal or a +window shows it, and is handed a terminal (`pardes --attach`) or a window +request (`pardes-gui --attach`) through it. Messages are `SOCK_SEQPACKET` +datagrams: a line of words and the fds it carries. -`src/detached/wire.zig` is the versioned protocol (version 10): fixed-width -little-endian fields, a 5-byte header (tag, then a u32 length), payloads up -to 16 MiB and grids up to 512 by 128. A comptime hash of `pardes.Chrome` -forces a version bump when that struct changes. +`pardes` in a terminal forks its session off before anything starts: the +session, in a session of its own (`setsid`), draws on the terminal it +opened, and the process the shell waits on stays as its stub, passing it +`SIGWINCH`, `SIGTERM`, `SIGINT` and `SIGQUIT` and ending with its status. +#word("Detach"), or the terminal's end (EIO, a hangup), puts +the terminal back and lets it go; the stub ends (exit 0) and the session +runs on with nothing drawn, until `pardes --attach` hands it another +terminal. A window's #word("Detach") closes the window and keeps the +process; `pardes-gui --attach` opens one again. `PARDES_DAEMON=off` (the +snapshot harness) runs a session as before the daemon: in the terminal's +own process, ended by its hangup. + +`src/detached/wire.zig` is the input half of the protocol a remote client +will speak (version 13): fixed-width little-endian fields, a 5-byte header +(tag, then a u32 length), the hello and its version, the input events. = 9P |
