diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 06:21:57 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 07:45:21 -0300 |
| commit | bbae7225e939daf4b6360d3de7af06c0fd95ce8d (patch) | |
| tree | dfd4fa1f7db63363a823d44b37aa168584c2ad14 /runtime | |
| parent | 744f1029ee2a02a43cb0fc70e32f70b60b100b75 (diff) | |
| download | pardes-bbae7225e939daf4b6360d3de7af06c0fd95ce8d.tar.gz pardes-bbae7225e939daf4b6360d3de7af06c0fd95ce8d.zip | |
pair: the process suite as pairs from 13 of 145 failing to 7 that stay (the goldens of one cause, open): the harness dials a pair's session, the launched client's child (test/process.zig `of`, `childOf`: it dialled the launched pid's socket); a Restore in a pair no daemon keeps is refused in words, as its Upgrade is (P42: runtime/session.zig `restore`: it let the client go and the session ended with its last link), and the three cases that Restore a pair run it with a daemon of their own root's (tty.zig `privateDaemon`, e2e_harness `PARDES_HARNESS_DAEMON`, process.zig `Detached.tty_daemon`, ended by `--kill-all` at its deinit); a pair's launch with no terminal says what the own path says and forks no session (main.zig `pair`, `noTerminal`: it said "pardes: NoDevice" after forking one); a terminal client ended by TERM or HUP dies of the signal once its goodbye is said and its terminal put back, as the own path's stub does (tui.zig `dieOfQuitSignal`: it exited 0 since pair-3), and the kill test takes a pair's hang-up as the close P36 ruled; PARDES_PAIR=1 process-test 8 of 145 (7 goldens of one family: resizes=2, a terminal panned in a view shorter than the one that sized it, a restored terminal's history; winch once), without the variable 0 of 145
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/main.zig | 17 | ||||
| -rw-r--r-- | runtime/session.zig | 4 |
2 files changed, 19 insertions, 2 deletions
diff --git a/runtime/main.zig b/runtime/main.zig index b0338831..aa35e687 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -1632,8 +1632,7 @@ fn nativeMain(std_init: std.process.Init) !void { // No controlling terminal (a detached pty, a daemon): said, not // an error trace. error.NoDevice => { - std.Io.File.stderr().writeStreamingAll(init.io, "pardes: no terminal to draw on: /dev/tty will not open; run it in a terminal, or --detach\n") catch {}; - std.process.exit(1); + noTerminal(init.io); }, else => return err, }, @@ -1761,6 +1760,13 @@ fn pardesBeside(buf: *[4104]u8) ?[:0]const u8 { /// the client exits. No fork to be had: returns, and this process is the /// session, with no terminal: said by the caller's run. A window with no /// `pardes` beside it returns at once, its own session as before. +/// A terminal's launch with no terminal to draw on (a detached pty, a +/// daemon): said, not an error trace, and exit 1. +fn noTerminal(io: std.Io) noreturn { + std.Io.File.stderr().writeStreamingAll(io, "pardes: no terminal to draw on: /dev/tty will not open; run it in a terminal, or --detach\n") catch {}; + std.process.exit(1); +} + fn pair(init: std.process.Init, opts: *pardes.Options, args: []const [:0]const u8) void { var path_buf: [4104]u8 = undefined; var fd_buf: [32]u8 = undefined; @@ -1771,6 +1777,13 @@ fn pair(init: std.process.Init, opts: *pardes.Options, args: []const [:0]const u argv[0] = path.ptr; for (args[1..], 2..) |a, k| argv[k] = a.ptr; } + // Its client draws on /dev/tty: none to be had, said as the own path + // says it, before a session is forked for nobody. + if (pardes.platform == .tui) { + const tty = std.c.open("/dev/tty", .{ .ACCMODE = .RDWR, .CLOEXEC = true }, @as(std.c.mode_t, 0)); + if (tty < 0) noTerminal(init.io); + _ = std.c.close(tty); + } const conn: ?c_int = if (pardes.platform == .tui and daemon.wanted()) daemon.connect(true) else null; var fds: [2]c_int = undefined; if (std.c.socketpair(std.c.AF.UNIX, std.c.SOCK.STREAM | std.c.SOCK.CLOEXEC, 0, &fds) != 0) diff --git a/runtime/session.zig b/runtime/session.zig index 60644aa6..5e99384e 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -188,6 +188,10 @@ pub fn Loop(comptime Frontend: type) type { /// let go (host_io.restoreCore); its shells and the frontend's /// devices with it. fn restore(l: *L, path: []const u8) void { + // A pair's session no daemon keeps: a Restore lets every client + // go, and its one could not join it again (no socket finds it): + // refused, as its Upgrade is (tui.zig `upgradeNow`). + if (l.peers.count() > 0 and daemon.link < 0) return l.core.reportFailure(l.core.view().active, "Restore: no daemon keeps this session, so its client could not join it again; this session stays as it is"); const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, l.watches.fd, &l.watches.table) orelse return; l.fe.restoring(nc); // The old core's pipes end, and an answer to its query is |
