summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tty/tty.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig
index 08964d73..994ebd92 100644
--- a/src/tty/tty.zig
+++ b/src/tty/tty.zig
@@ -1585,15 +1585,18 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se
if (init.environ_map.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file);
if (!link.gone) replica.bye(joined.fd);
// The link's reader ends with the link, posting as it goes: what it
- // and the terminal posted is let go until it has.
+ // and the terminal posted is let go until it has. Its end is read
+ // before the drain, not after: its last post (`link_gone`) comes
+ // just before it, and left queued it ended the next link at once.
_ = libc.shutdown(joined.fd, 2);
while (true) {
+ const ended = reader_done.load(.acquire);
while (loop.tryEvent() catch null) |ev| switch (ev) {
.unit, .screen, .refused => |b| std.heap.c_allocator.free(b),
.paste => |b| gpa.free(@constCast(b)),
else => {},
};
- if (reader_done.load(.acquire)) break;
+ if (ended) break;
std.Thread.yield() catch {};
}
reader.join();