From 288a88aa1540d2c361c68a5009be642c070f33d6 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sun, 15 Oct 2017 23:15:49 +0200 Subject: [PATCH] Fix error applying new stdout settings On Fedora 26 tio will quit with the following error message: "Error: Could not apply new stdout settings (Invalid argument)" In case of Fedora, it turns out that the new stdout settings used are a bit too agressive because an empty termios structure is used. To remedy this we reuse the existing stdout settings and only reconfigure the specific options we need to make a "raw" stdout configuration. --- src/tty.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tty.c b/src/tty.c index 2b1705b..88de59b 100644 --- a/src/tty.c +++ b/src/tty.c @@ -173,13 +173,11 @@ void stdout_configure(void) } /* Prepare new stdout settings */ - memset(&new_stdout, 0, sizeof(new_stdout)); + memcpy(&new_stdout, &old_stdout, sizeof(old_stdout)); - /* Control, input, output, local modes for stdout */ - new_stdout.c_cflag = 0; - new_stdout.c_iflag = 0; - new_stdout.c_oflag = 0; - new_stdout.c_lflag = 0; + /* Reconfigure stdout (RAW configuration) */ + new_stdout.c_oflag &= ~(OPOST); + new_stdout.c_lflag &= ~(ECHO|ICANON|ISIG|ECHOE|ECHOK|ECHONL); /* Control characters */ new_stdout.c_cc[VTIME] = 0; /* Inter-character timer unused */