summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2005-05-24 16:09:34 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2005-05-24 16:09:34 +0000
commit01f88fc9c9c139d1700223a93857ef9adbcfbd26 (patch)
tree5fbc29a768a1373937cb4ac422457fd1b4a56448 /lib/libc/gen
parent9b57d7766280c985fd97662aa2c10563e6e17d80 (diff)
Restoration of terminal settings can be broken by a well-timed signal,
e.g. a terminating scp killing its ssh child so retry on EINTR. From peak@argo.troja.mff.cuni.cz via portable openssh bugzilla #905
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/readpassphrase.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/gen/readpassphrase.c b/lib/libc/gen/readpassphrase.c
index 2eb7eb5d69d..ece1423d509 100644
--- a/lib/libc/gen/readpassphrase.c
+++ b/lib/libc/gen/readpassphrase.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $ */
+/* $OpenBSD: readpassphrase.c,v 1.17 2005/05/24 16:09:33 millert Exp $ */
/*
* Copyright (c) 2000-2002 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -21,7 +21,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $";
+static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.17 2005/05/24 16:09:33 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <ctype.h>
@@ -126,8 +126,11 @@ restart:
(void)write(output, "\n", 1);
/* Restore old terminal settings and signals. */
- if (memcmp(&term, &oterm, sizeof(term)) != 0)
- (void)tcsetattr(input, TCSANOW|TCSASOFT, &oterm);
+ if (memcmp(&term, &oterm, sizeof(term)) != 0) {
+ while (tcsetattr(input, TCSANOW|TCSASOFT, &oterm) == -1 &&
+ errno == EINTR)
+ continue;
+ }
(void)sigaction(SIGALRM, &savealrm, NULL);
(void)sigaction(SIGHUP, &savehup, NULL);
(void)sigaction(SIGINT, &saveint, NULL);