Only manipulate output terminal state if it is a terminal

This commit is contained in:
Marc André Tanner 2018-03-17 10:38:21 +01:00
parent fdbda93131
commit 3e3308d4e3
1 changed files with 5 additions and 2 deletions

View File

@ -22,8 +22,9 @@ static bool client_recv_packet(Packet *pkt) {
}
static void client_restore_terminal(void) {
if (has_term)
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_term);
if (!has_term)
return;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_term);
if (alternate_buffer) {
printf("\033[?25h\033[?1049l");
fflush(stdout);
@ -32,6 +33,8 @@ static void client_restore_terminal(void) {
}
static void client_setup_terminal(void) {
if (!has_term)
return;
atexit(client_restore_terminal);
cur_term = orig_term;