From 7f28dbee65cef6e1990552c3eb3eb450ef9e98f2 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 28 Jun 1996 07:06:34 +0000 Subject: [PATCH] standard input on server may be nonblocking --- io.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/io.c b/io.c index b7d27e62..38868751 100644 --- a/io.c +++ b/io.c @@ -103,8 +103,15 @@ static int readfd(int fd,char *buffer,int N) read_buffer_p += ret; read_buffer_len -= ret; } else { - if ((ret = read(fd,buffer + total,N - total)) == -1) - return -1; + while ((ret = read(fd,buffer + total,N - total)) == -1) { + fd_set fds; + + if (errno != EAGAIN && errno != EWOULDBLOCK) + return -1; + FD_ZERO(&fds); + FD_SET(fd, &fds); + select(fd+1, &fds, NULL, NULL, NULL); + } } if (ret <= 0) @@ -194,7 +201,7 @@ static int writefd(int fd,char *buf,int len) FD_SET(fd,&fds); tv.tv_sec = BLOCKING_TIMEOUT; tv.tv_usec = 0; - select(16,NULL,&fds,NULL,&tv); + select(fd+1,NULL,&fds,NULL,&tv); } else { total += ret; } -- 2.34.1