From: Ray Strode Date: Thu, 23 Oct 2008 21:06:28 +0000 (-0400) Subject: Make sure set_buffered_input() works X-Git-Tag: 0.6.0~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43735d445c5267f12ce49cd013c3e42b507eaec7;p=thirdparty%2Fplymouth.git Make sure set_buffered_input() works There are cases, it seems, where we end up stuck in raw mode on exit. This should make sure that won't happen. --- diff --git a/src/libplybootsplash/ply-window.c b/src/libplybootsplash/ply-window.c index b44292d3..d802eefe 100644 --- a/src/libplybootsplash/ply-window.c +++ b/src/libplybootsplash/ply-window.c @@ -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;