From 777eaa2168bc2a4e7d0a404010d8ec2ec5433c73 Mon Sep 17 00:00:00 2001 From: Rafal Wojtczuk Date: Wed, 16 Mar 2011 12:58:40 +0100 Subject: [PATCH] In read_all()/write_all(), continue upon EINTR. --- common/ioall.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/ioall.c b/common/ioall.c index 413477fc..a99a8aac 100644 --- a/common/ioall.c +++ b/common/ioall.c @@ -31,6 +31,8 @@ int write_all(int fd, void *buf, int size) int ret; while (written < size) { ret = write(fd, (char *) buf + written, size - written); + if (ret == -1 && errno == EINTR) + continue; if (ret <= 0) { perror("write"); return 0; @@ -47,6 +49,8 @@ int read_all(int fd, void *buf, int size) int ret; while (got_read < size) { ret = read(fd, (char *) buf + got_read, size - got_read); + if (ret == -1 && errno == EINTR) + continue; if (ret == 0) { errno = 0; fprintf(stderr, "EOF\n"); @@ -68,6 +72,8 @@ int copy_fd_all(int fdout, int fdin) char buf[4096]; for (;;) { ret = read(fdin, buf, sizeof(buf)); + if (ret == -1 && errno == EINTR) + continue; if (!ret) break; if (ret < 0) { @@ -81,4 +87,3 @@ int copy_fd_all(int fdout, int fdin) } return 1; } -