Use TCSAFLUSH when restoring terminal settings (and echo) to guarantee that any pending output is discarded

This commit is contained in:
Todd C. Miller
2008-01-16 18:03:08 +00:00
parent fb4b049788
commit ebcf3cf399

View File

@@ -107,8 +107,6 @@ __unused static const char rcsid[] = "$Sudo$";
# define tcsetattr(f, a, t) ioctl(f, a, t)
# undef TCSAFLUSH
# define TCSAFLUSH TCSETAF
# undef TCSANOW
# define TCSANOW TCSETA
# else
# undef termios
# define termios sgttyb
@@ -117,8 +115,6 @@ __unused static const char rcsid[] = "$Sudo$";
# define tcsetattr(f, a, t) ioctl(f, a, t)
# undef TCSAFLUSH
# define TCSAFLUSH TIOCSETP
# undef TCSANOW
# define TCSANOW TIOCSETN
# endif /* HAVE_TERMIO_H */
#endif /* HAVE_TERMIOS_H */
@@ -202,7 +198,7 @@ restart:
/* Restore old tty settings and signals. */
if (memcmp(&term, &oterm, sizeof(term)) != 0) {
while (tcsetattr(input, TCSANOW|TCSASOFT, &oterm) == -1 &&
while (tcsetattr(input, TCSAFLUSH|TCSASOFT, &oterm) == -1 &&
errno == EINTR)
continue;
}