diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 18:08:49 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 18:08:49 -0300 |
| commit | 4053e62a2aabd794db9075d93ebe57eec3f432a6 (patch) | |
| tree | b5a676e835b4df79f0670056a636410c97ffb8fd /dev/tui/tui.zig | |
| parent | e3d0daa9f89f41b41b7d05d510db553cbd8816d9 (diff) | |
| parent | 6683e03a40c0bbd88dadf6bb30121d41e944207c (diff) | |
| download | pardes-4053e62a2aabd794db9075d93ebe57eec3f432a6.tar.gz pardes-4053e62a2aabd794db9075d93ebe57eec3f432a6.zip | |
integration: a hang-up is a close and a session can be kept, on the 9P state a join carries: pardes-pair-3 (a session's state as the daemon hears it: attached, detached, pair or kept, carried through an Upgrade; a terminal client takes HUP and TERM itself and leaves with a goodbye that closes; ps shows (tty) for a pair and (tty, kept); the documents say what PARDES_PAIR is) and pardes-merge40, merged without a textual conflict; tui core-test 871/1028 (157 skipped), shell-test 1070/1073, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge41)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/tui/tui.zig')
| -rw-r--r-- | dev/tui/tui.zig | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index 72028b04..67c0e2a0 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -721,19 +721,22 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, std.process.exit(1); } }; - var start: client_loop.Start = undefined; - if (!start.open(init, opts, .{ .path = path, .session = session, .far = far_link })) Said.no(io, "{s}", .{start.said()}); - defer start.close(); - + // Blocked before its join makes a thread, so that winchWatch alone + // takes them: a hangup (its terminal closed) or a TERM ends it the + // normal way (`quit`), its goodbye a close (a pair's session not kept + // ends at its last client's), what it made kept on disk (`Have.keep`) + // and its ssh forward's socket unlinked (main.zig). var winch_set = posix.sigemptyset(); posix.sigaddset(&winch_set, posix.SIG.WINCH); - // A hangup ends it the normal way (`quit`), what it made kept on disk - // (`Have.keep`) and its ssh forward's socket unlinked (main.zig). posix.sigaddset(&winch_set, posix.SIG.HUP); + posix.sigaddset(&winch_set, posix.SIG.TERM); hangup_quits = true; if (comptime builtin.os.tag == .freebsd) posix.sigaction(.WINCH, &.{ .handler = .{ .handler = keepSignal }, .mask = posix.sigemptyset(), .flags = 0 }, null); posix.sigprocmask(posix.SIG.BLOCK, &winch_set, null); + var start: client_loop.Start = undefined; + if (!start.open(init, opts, .{ .path = path, .session = session, .far = far_link })) Said.no(io, "{s}", .{start.said()}); + defer start.close(); var tty_buf: [0x10000]u8 = undefined; var screen: Screen = .{ .io = io, .gpa = gpa, .env = init.environ_map, .buf = &tty_buf, .kitty = .init(gpa) }; defer screen.kitty.deinit(); @@ -1544,7 +1547,10 @@ const Shell = struct { virtual.* = @max(virtual.*, s.wake_to); }, .quit => { + // A client's terminal went (a hangup, its input's end) or it + // took a TERM: a close, as a window's close button. if (s.client) |c| { + c.link.close = true; c.link.quit = true; return true; } @@ -1939,19 +1945,20 @@ const Shell = struct { fn keepSignal(_: posix.SIG) callconv(.c) void {} -/// A replica client's (`runClient`): a hangup is its end, whoever sent it. +/// A replica client's (`runClient`): a hangup or a TERM is its end. var hangup_quits = false; fn winchWatch(loop: *Loop) void { var set = posix.sigemptyset(); posix.sigaddset(&set, posix.SIG.WINCH); if (daemon.link >= 0 or hangup_quits) posix.sigaddset(&set, posix.SIG.HUP); + if (hangup_quits) posix.sigaddset(&set, posix.SIG.TERM); while (true) { var sig: c_int = 0; if (libc.sigwait(&set, &sig) != 0) continue; // The terminals are the loop's: it asks each its size, and takes a // hangup as the end of the one that hung up. - const ev: Msg = if (sig != @backingInt(posix.SIG.HUP)) .winched else if (hangup_quits) .quit else .hangup; + const ev: Msg = if (sig == @backingInt(posix.SIG.WINCH)) .winched else if (hangup_quits) .quit else .hangup; loop.postEvent(ev) catch {}; } } |
