From ae06668733d4700e04da6deefead0e9de0862251 Mon Sep 17 00:00:00 2001 From: brian Date: Mon, 13 Dec 2004 14:50:13 +0000 Subject: Handle select() returning -1/EINTR - fairly common in these KSE days. PR: 74972 MFC after: 3 days --- usr.sbin/pppctl/pppctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'usr.sbin/pppctl') diff --git a/usr.sbin/pppctl/pppctl.c b/usr.sbin/pppctl/pppctl.c index 1ff63b3..d8e7b42 100644 --- a/usr.sbin/pppctl/pppctl.c +++ b/usr.sbin/pppctl/pppctl.c @@ -124,6 +124,7 @@ Receive(int fd, int display) char *last; fd_set f; int len; + int err; FD_ZERO(&f); FD_SET(fd, &f); @@ -133,7 +134,7 @@ Receive(int fd, int display) len = 0; while (Result = read(fd, Buffer+len, sizeof(Buffer)-len-1), Result != -1) { - if (Result == 0 && errno != EINTR) { + if (Result == 0) { Result = -1; break; } @@ -186,8 +187,11 @@ Receive(int fd, int display) len -= flush; } if ((Result = select(fd + 1, &f, NULL, NULL, &t)) <= 0) { + err = Result == -1 ? errno : 0; if (len) write(STDOUT_FILENO, Buffer, len); + if (err == EINTR) + continue; break; } } -- cgit v1.1