mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Handle select() returning -1/EINTR - fairly common in these KSE days.
PR: 74972 MFC after: 3 days
This commit is contained in:
parent
2d59a44dc0
commit
cf4bdb6e94
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138808
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user