[Spice-devel] [PATCH spice-gtk] spicy: fix reset of terminal when quit

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Fri Oct 7 11:27:09 UTC 2016


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Only restore the terminal if it was actually saved.

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 src/spicy.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/spicy.c b/src/spicy.c
index 92de251..c502428 100644
--- a/src/spicy.c
+++ b/src/spicy.c
@@ -1818,14 +1818,18 @@ static void setup_terminal(gboolean reset)
         return;
 
 #ifdef HAVE_TERMIOS_H
-    static struct termios saved_tios;
     struct termios tios;
+    static struct termios saved_tios;
+    static bool saved = false;
 
-    if (reset)
+    if (reset) {
+        if (!saved)
+            return;
         tios = saved_tios;
-    else {
+    } else {
         tcgetattr(stdinfd, &tios);
         saved_tios = tios;
+        saved = true;
         tios.c_lflag &= ~(ICANON | ECHO);
     }
 
-- 
2.10.0



More information about the Spice-devel mailing list