- commit
- 984a184
- parent
- 8640be5
- author
- Eric Bower
- date
- 2025-11-26 20:11:44 -0500 EST
fix: discard any unread input when restoring terminal settings on detach
1 files changed,
+2,
-1
+2,
-1
1@@ -402,8 +402,9 @@ fn attach(daemon: *Daemon) !void {
2 _ = c.tcgetattr(posix.STDIN_FILENO, &orig_termios);
3
4 // restore stdin fd to its original state and exit alternate buffer after exiting.
5+ // Use TCSAFLUSH to discard any unread input, preventing stale input after detach.
6 defer {
7- _ = c.tcsetattr(posix.STDIN_FILENO, c.TCSANOW, &orig_termios);
8+ _ = c.tcsetattr(posix.STDIN_FILENO, c.TCSAFLUSH, &orig_termios);
9 // Restore normal buffer and show cursor
10 const restore_seq = "\x1b[?25h\x1b[?1049l";
11 _ = posix.write(posix.STDOUT_FILENO, restore_seq) catch {};