From 3e3308d4e3a9f46c60d2eaa99361233c999dab27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 17 Mar 2018 10:38:21 +0100 Subject: [PATCH] Only manipulate output terminal state if it is a terminal --- client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 6cf70c7..0e6f7a1 100644 --- a/client.c +++ b/client.c @@ -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;