From: Todd C. Miller Date: Thu, 15 Oct 1998 03:28:21 +0000 (+0000) Subject: catch EINTR in select and restart X-Git-Tag: SUDO_1_5_7~101 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a05c2b96b4755dd92f98a22df98f361cad6621b8;p=sudo catch EINTR in select and restart --- diff --git a/tgetpass.c b/tgetpass.c index b01b5269f..dca735828 100644 --- a/tgetpass.c +++ b/tgetpass.c @@ -56,6 +56,7 @@ static char rcsid[] = "$Id$"; #include #endif /* HAVE_SYS_SELECT_H */ #include +#include #include #include #ifdef HAVE_TERMIOS_H @@ -216,8 +217,10 @@ char * tgetpass(prompt, timeout, user, host) * get password or return empty string if nothing to read by timeout */ buf[0] = '\0'; - if (select(fileno(input) + 1, readfds, 0, 0, &tv) > 0 && - fgets(buf, sizeof(buf), input)) { + while ((n = select(fileno(input) + 1, readfds, 0, 0, &tv)) == -1 && + errno == EINTR) + ; + if (n > 0 && fgets(buf, sizeof(buf), input)) { n = strlen(buf); if (buf[n - 1] == '\n') buf[n - 1] = '\0';