ptyfwd: reset tty when exiting

Let's do a "soft" reset of the TTY when a ptyfwd session ends. This is a
good idea, in order to reset changes to the scrolling window that code
inside the session might have made. A "soft" reset will undo this.

While we are at it, make sure to output the ansi sequences for this
*after* terminating any half-written line, as that is still somewhat
contents of the session, even if it's augmented.
This commit is contained in:
Lennart Poettering
2025-09-22 14:39:05 +09:00
committed by Yu Watanabe
parent e6a05af50b
commit 3d97db8f3c
3 changed files with 10 additions and 8 deletions
+1 -1
View File
@@ -955,7 +955,7 @@ finish:
return r;
}
static int terminal_reset_ansi_seq(int fd) {
int terminal_reset_ansi_seq(int fd) {
int r, k;
assert(fd >= 0);
+2
View File
@@ -34,6 +34,8 @@
bool isatty_safe(int fd);
int terminal_reset_ansi_seq(int fd);
typedef enum TerminalResetFlags {
TERMINAL_RESET_SWITCH_TO_TEXT = 1 << 0,
TERMINAL_RESET_AVOID_ANSI_SEQ = 1 << 1,