diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-29 10:48:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-29 12:01:27 -0300 |
| commit | cb2a6cd79e443d671f5255d262ea79b7e26552a5 (patch) | |
| tree | c11e04d42ca3f0f06cb9f0332ebd7d5b76823ed0 /src/detached | |
| parent | a73697397ee3f2b7fa7cba08c96f6f81ff7ee04c (diff) | |
| download | pardes-cb2a6cd79e443d671f5255d262ea79b7e26552a5.tar.gz pardes-cb2a6cd79e443d671f5255d262ea79b7e26552a5.zip | |
daemon.zig: one pardes daemon per user, holding pty masters and handing terminals to detached sessions
`pardes --daemon` listens on pardes-daemon.sock in the runtime directory (ninep_io.socketDir), its .lock flocked for its life so two never run. The first session that finds none takes the lock, binds and listens itself and queues its own connection; the daemon is then double-forked and exec'd onto that listener and lock (fds 3 and 4), by a terminal's stub after the session's fork, so no startup waits for it: the hello sits queued, and the `ok` is the reader thread's. Another starter waits on the lock; a stale socket is the lock holder's to replace. Idle a second (no connection, no master held), it unlinks the socket and exits.
It spawns nothing and is nobody's parent: a session registers on one connection (hello: kind, pid, name, attached or detached), sends a dup of every pty master it forks (`pty`), says which it closed (`close`) and when it ends (`quit`, its shells hang up), and asks for the masters of sessions that died holding them (`adopt`). A master whose shell is gone (POLLHUP, polled with no events, its output never read here) is dropped. `attach` hands a terminal and a stub's pipe (pardes --attach), or a window request (pardes-gui --attach), to the detached session of that name or the only one, and refuses in words: no such session, attached already, the other kind. SOCK_SEQPACKET datagrams, a line of words and the fds they carry.
The client half: connect (starting one), register, the session's link and its reader thread, and the stub a terminal's session leaves behind (forkSession, stubWait), which passes WINCH, TERM, INT, QUIT and HUP on and ends with the session's status.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/detached')
0 files changed, 0 insertions, 0 deletions
