2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

catch EINTR in select and restart

This commit is contained in:
Todd C. Miller
1998-10-15 03:28:21 +00:00
parent d680945141
commit a05c2b96b4

View File

@@ -56,6 +56,7 @@ static char rcsid[] = "$Id$";
#include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H */
#include <sys/time.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#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';