diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 09:10:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 09:10:24 -0300 |
| commit | c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437 (patch) | |
| tree | 9b60bce9e53f96855b40f2ba53e23945a7798ddf /runtime | |
| parent | f7de6f49ee3d9ac241575f5244743193c9943841 (diff) | |
| parent | 5ad6067936f306271b875aaf182d4866055da10d (diff) | |
| download | pardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.tar.gz pardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.zip | |
integration: the pair's round 5 and the layers' round 2 on the gathered line: pardes-pair-5 (`ssrtxkzx`, on pardes-merge48: a link an Upgrade cuts with no last word asks the daemon whether its session is listed still and joins again (`replica.cutListed`): an upgrade from the installed build carries its clients; a no-daemon pair refuses Restore in words (P42); /dev/tty opened before the pair forks; a TERMed or hung-up client dies of the signal; the process suite as pairs 13 to 8 of 145) and pardes-layers-2 (`myxnnquu`, on pardes-merge49: the click on path@rev tested, a revision read-only from 9P, Syntax off in a patch keeps the patch's colours); no conflict; core-test 893/1053 (160 skipped), shell-test 1095/1098; its gate: .scratch/sketch/reorg/merge50, the numbers in PARDES.md (2026-11-21)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/client.zig | 19 | ||||
| -rw-r--r-- | runtime/main.zig | 17 | ||||
| -rw-r--r-- | runtime/session.zig | 4 |
3 files changed, 33 insertions, 7 deletions
diff --git a/runtime/client.zig b/runtime/client.zig index d4b76a1b..49ebbc6e 100644 --- a/runtime/client.zig +++ b/runtime/client.zig @@ -129,24 +129,29 @@ pub fn execAgain(s: *Start, view: u8, size: ?[2]c_int) []const u8 { const path = upgrade.exe() orelse return "Upgrade: this client does not know the path it was started from"; var at_buf: [4200]u8 = undefined; const at = std.fmt.bufPrintSentinel(&at_buf, "--attach={s}:{s}", .{ s.dial.path, s.dial.session }, 0) catch return "Upgrade: the session's socket's path is too long to attach again by"; - // A window's new window the size it had (`--geometry`), not the default. + const argv = [_:null]?[*:0]const u8{ path, at }; + // A window's new window the size it had (gui.zig reads it as a + // `--geometry`), not the default. var size_buf: [48]u8 = undefined; - const geometry: ?[*:0]const u8 = if (size) |wh| (std.fmt.bufPrintSentinel(&size_buf, "--geometry={d}x{d}", .{ wh[0], wh[1] }, 0) catch unreachable).ptr else null; // two c_ints fit 48 - const argv = [_:null]?[*:0]const u8{ path, at, geometry }; + const sized: ?[*:0]const u8 = if (size) |wh| (std.fmt.bufPrintSentinel(&size_buf, "PARDES_JOIN_SIZE={d}x{d}", .{ wh[0], wh[1] }, 0) catch unreachable).ptr else null; // two c_ints fit 48 var view_buf: [32]u8 = undefined; const joining = std.fmt.bufPrintSentinel(&view_buf, "PARDES_JOIN_VIEW={d}", .{view}, 0) catch unreachable; // a u8 fits 32 var n: usize = 0; while (libc.environ[n] != null) n += 1; - const envp = s.gpa.allocSentinel(?[*:0]const u8, n + 2, null) catch return "Upgrade: no memory for this client's environment"; + const envp = s.gpa.allocSentinel(?[*:0]const u8, n + 3, null) catch return "Upgrade: no memory for this client's environment"; var k: usize = 0; for (libc.environ[0..n]) |e| { const entry = std.mem.span(e.?); - if (std.mem.startsWith(u8, entry, "PARDES_JOIN_VIEW=") or std.mem.startsWith(u8, entry, "PARDES_REPLICA_FAR=")) continue; + if (std.mem.startsWith(u8, entry, "PARDES_JOIN_VIEW=") or std.mem.startsWith(u8, entry, "PARDES_JOIN_SIZE=") or std.mem.startsWith(u8, entry, "PARDES_REPLICA_FAR=")) continue; envp[k] = e; k += 1; } envp[k] = joining.ptr; k += 1; + if (sized) |e| { + envp[k] = e; + k += 1; + } if (s.have != null) { envp[k] = "PARDES_REPLICA_FAR=1"; k += 1; @@ -218,6 +223,10 @@ pub fn Loop(comptime Frontend: type) type { reader.join(); _ = libc.close(s.joined.fd); s.joined.rest.deinit(s.gpa); + // Its link cut with no word by a session that is there still + // (an Upgrade's exec): joined again, as when told so. + if (link.gone and link.refused == null and link.ended == null and !link.left and replica.cutListed("the session hung up", s.dial.session, s.have != null)) + link.refused = std.heap.c_allocator.dupe(u8, replica.upgrading) catch null; // Why it joins again is in its notice until a key. if (!link.rejoins()) { // What it made since it joined, kept for its next start. 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 |
