summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dev/tui/tui.zig16
-rw-r--r--test/process/flags.zig2
2 files changed, 12 insertions, 6 deletions
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 9117d54d..5d75722f 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -901,12 +901,14 @@ const Screen = struct {
fn leave(sc: *Screen) void {
if (!sc.on) return;
sc.on = false;
- Killed.disarm();
clearNativeImages(&sc.kitty, &sc.vx, &sc.tty);
sc.vx.exitAltScreen(sc.tty.writer()) catch {};
sc.vx.deinit(sc.gpa, sc.tty.writer());
if (comptime !builtin.is_test) vaxis.tty.global_tty = null;
- sc.tty.deinit(); // restore cooked termios LAST, after vx flushed its resets
+ // The cooked modes back LAST, after vx flushed its resets, and Killed
+ // armed until they are.
+ Killed.disarm();
+ sc.tty.deinit();
}
/// Its terminal hung up, or the stub that waits on it is gone.
@@ -950,10 +952,14 @@ const Killed = struct {
_ = std.c.tcsetattr(tty, .FLUSH, termios);
}
- /// The terminal gone (put back, or detached): a TERM still takes the
- /// socket, the prompt files and the shells with it, and leaves the
- /// terminal alone.
+ /// The terminal let go (Screen.leave): its cooked modes put back first,
+ /// so that a TERM anywhere in a leave finds them back or puts them back
+ /// itself (let go first, a TERM before vaxis put them back died leaving
+ /// the terminal raw for good); then a TERM still takes the socket,
+ /// the prompt files and the shells with it, and leaves the terminal
+ /// alone.
fn disarm() void {
+ if (fd >= 0) _ = std.c.tcsetattr(fd, .FLUSH, &cooked);
fd = -1;
}
diff --git a/test/process/flags.zig b/test/process/flags.zig
index cfdb1faf..3c54a7ad 100644
--- a/test/process/flags.zig
+++ b/test/process/flags.zig
@@ -746,7 +746,7 @@ fn killedTty(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
const seen = try d.get(a, std.fs.path.basename(log));
const tail = seen[std.mem.lastIndexOf(u8, seen, "\x1b[?1049h").?..];
try check(has(tail, "\x1b[?1049l"), "the main screen not put back", .{});
- try check(try process.canonical(killed.slave), "the terminal left raw", .{});
+ try check(try process.canonical(killed.slave), "{t}: the terminal left raw", .{sig});
daemonGone(&d);
}
}