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:
committed by
Yu Watanabe
parent
e6a05af50b
commit
3d97db8f3c
+7
-7
@@ -133,13 +133,6 @@ static void pty_forward_disconnect(PTYForward *f) {
|
||||
/* STDIN/STDOUT should not be non-blocking normally, so let's reset it */
|
||||
(void) fd_nonblock(f->output_fd, false);
|
||||
|
||||
if (colors_enabled()) {
|
||||
(void) loop_write(f->output_fd, ANSI_NORMAL ANSI_ERASE_TO_END_OF_SCREEN, SIZE_MAX);
|
||||
|
||||
if (f->title)
|
||||
(void) loop_write(f->output_fd, ANSI_WINDOW_TITLE_POP, SIZE_MAX);
|
||||
}
|
||||
|
||||
if (f->last_char_set && f->last_char != '\n') {
|
||||
const char *s;
|
||||
|
||||
@@ -153,6 +146,13 @@ static void pty_forward_disconnect(PTYForward *f) {
|
||||
f->last_char = '\n';
|
||||
}
|
||||
|
||||
if (colors_enabled()) {
|
||||
if (f->title)
|
||||
(void) loop_write(f->output_fd, ANSI_WINDOW_TITLE_POP, SIZE_MAX);
|
||||
|
||||
terminal_reset_ansi_seq(f->output_fd);
|
||||
}
|
||||
|
||||
if (f->close_output_fd)
|
||||
f->output_fd = safe_close(f->output_fd);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user