diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 02:49:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 03:13:15 -0300 |
| commit | 349cf7b0062b7881e868fb5adc996b2e642b76f7 (patch) | |
| tree | 70613ee47926792074019b5144965258f94d9755 /src/tty/tty.zig | |
| parent | c892cf0c3246b6c41f8f67810d360c5ea0ff66ef (diff) | |
| download | pardes-349cf7b0062b7881e868fb5adc996b2e642b76f7.tar.gz pardes-349cf7b0062b7881e868fb5adc996b2e642b76f7.zip | |
tty: a terminal attached while a replica client's view is live takes the session's own screen: the live view has no terminal here, and the attach returned without a word, its stub waiting and its terminal blank (the main test's third terminal, on the box)
test/daemon.py: the clients test attaches one while a client's view is live.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tty/tty.zig')
| -rw-r--r-- | src/tty/tty.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index b4eb6be9..08964d73 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -2320,7 +2320,14 @@ const Shell = struct { /// entered as the first one was; for one attached already, a view of /// its own (views.zig). Sized, asked what it can do, and drawn whole. fn attachTerminal(s: *Shell, fd: posix.fd_t, stub: posix.fd_t, cooked: ?posix.termios) void { - const live = s.term() orelse return; + // A replica client's view live (its input the last) has no terminal + // here: the session's own is the one a terminal takes, or joins. + const live = s.term() orelse for (s.terms) |slot| { + if (slot) |sc| if (sc.primary) break sc; + } else { + _ = libc.close(fd); + return refuse(stub, "that session has no terminal of its own to attach to"); + }; const screen = if (!live.on) live else extra: { const sc = s.gpa.create(Screen) catch break :extra null; const buf = s.gpa.alloc(u8, 0x10000) catch { |
