From d87f1804677bafcee92e419a4815ba1a2fb86371 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 2 May 1995 15:26:52 +0000 Subject: [PATCH] EINTR obvserved on reads and writes. --- util/gip.c | 37 +++++++++++++++++++++++++------------ util/lgets.c | 13 ++++++++++--- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/util/gip.c b/util/gip.c index f0c02a4..8265d49 100644 --- a/util/gip.c +++ b/util/gip.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: gip.c,v $ - * Revision 1.5 1995/05/01 16:27:28 adam + * Revision 1.6 1995/05/02 15:26:52 adam + * EINTR obvserved on reads and writes. + * + * Revision 1.5 1995/05/01 16:27:28 adam * Various improvements. Close-on-exec and close on failure on either * read or write FIFO. * @@ -83,12 +86,17 @@ int gip_read (GIP gip, char *buf, size_t count) int r, no = 0; while (no < count) { - r = read (gip->rfd, buf+no, count-no); - if (r == -1) - { - gip->errno = errno; - return -1; - } + while (1) + { + r = read (gip->rfd, buf+no, count-no); + if (r != -1) + break; + if (errno != EINTR) + { + gip->errno = errno; + return -1; + } + } no += r; } return 0; @@ -99,11 +107,16 @@ int gip_write (GIP gip, const char *buf, size_t count) int r, no = 0; while (no < count) { - r = write (gip->wfd, buf+no, count-no); - if (r == -1) - { - gip->errno = errno; - return -1; + while (1) + { + r = write (gip->wfd, buf+no, count-no); + if (r != -1) + break; + if (errno != EINTR) + { + gip->errno = errno; + return -1; + } } no += r; } diff --git a/util/lgets.c b/util/lgets.c index 77e5b49..9b9285b 100644 --- a/util/lgets.c +++ b/util/lgets.c @@ -2,7 +2,10 @@ * Europagate, 1995 * * $Log: lgets.c,v $ - * Revision 1.1 1995/05/01 12:43:58 adam + * Revision 1.2 1995/05/02 15:26:52 adam + * EINTR obvserved on reads and writes. + * + * Revision 1.1 1995/05/01 12:43:58 adam * lgets function moved from kernel to util. * */ @@ -24,8 +27,12 @@ int lgets (char *buf, int max, int fd) --max; while (no <= max) { - if ((r=read (fd, buf+no, 1)) != 1) - { + while (1) + { + if ((r=read (fd, buf+no, 1)) == 1) + break; + if (r == -1 && errno == EINTR) + continue; if (r == -1) gw_log (GW_LOG_WARN|GW_LOG_ERRNO, "lgets", "read fail"); else -- 1.7.10.4