]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Make sure set_buffered_input() works
authorRay Strode <rstrode@redhat.com>
Thu, 23 Oct 2008 21:06:28 +0000 (17:06 -0400)
committerRay Strode <rstrode@redhat.com>
Thu, 23 Oct 2008 21:07:43 +0000 (17:07 -0400)
There are cases, it seems, where we end up stuck in
raw mode on exit.  This should make sure that won't happen.

src/libplybootsplash/ply-window.c

index b44292d360baf0119d408df18175907e6590a6cf..d802eefe880ee7e3b690c928afba161bc9f8c9f9 100644 (file)
@@ -402,8 +402,30 @@ ply_window_set_unbuffered_input (ply_window_t *window)
 static bool
 ply_window_set_buffered_input (ply_window_t *window)
 {
-  if (!window->original_term_attributes_saved)
-    return false;
+  struct termios term_attributes;
+
+  tcgetattr (window->tty_fd, &term_attributes);
+
+  /* If someone already messed with the terminal settings,
+   * and they seem good enough, bail
+   */
+  if (term_attributes.c_lflag & ICANON)
+    return true;
+
+  /* If we don't know the original term attributes, or they were originally sucky,
+   * then invent some that are probably good enough.
+   */
+  if (!window->original_term_attributes_saved || !(window->original_term_attributes.c_lflag & ICANON))
+    {
+       term_attributes.c_iflag |= IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON;
+       term_attributes.c_oflag |= OPOST;
+       term_attributes.c_lflag |= ECHO | ECHONL | ICANON | ISIG | IEXTEN;
+
+       if (tcsetattr (window->tty_fd, TCSAFLUSH, &window->original_term_attributes) != 0)
+           return false;
+
+       return true;
+    }
 
   if (tcsetattr (window->tty_fd, TCSAFLUSH, &window->original_term_attributes) != 0)
     return false;