diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-07-18 12:57:53 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2022-07-18 12:57:53 +0000 |
commit | 43dde3b628331bf43cacc93e85c676ffa9a76e2f (patch) | |
tree | 057aa1a485f0eaee84e41e8a0def7d00d501f553 | |
parent | 536eea15284be9a257b6f97f971e0d8d4a7e437b (diff) | |
download | s6-portable-utils-43dde3b628331bf43cacc93e85c676ffa9a76e2f.tar.gz s6-portable-utils-43dde3b628331bf43cacc93e85c676ffa9a76e2f.tar.xz s6-portable-utils-43dde3b628331bf43cacc93e85c676ffa9a76e2f.zip |
Fix allread errno management
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r-- | src/skaembutils/s6-head.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/skaembutils/s6-head.c b/src/skaembutils/s6-head.c index 427d220..217880b 100644 --- a/src/skaembutils/s6-head.c +++ b/src/skaembutils/s6-head.c @@ -3,6 +3,7 @@ #include <sys/types.h> #include <sys/uio.h> #include <errno.h> + #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> @@ -60,8 +61,10 @@ static int safedolines (int fd, size_t lines) char tmp[lines] ; while (lines) { - size_t r = allread(fd, tmp, lines) ; - if ((r < lines) && (errno != EPIPE)) return 0 ; + size_t r ; + errno = 0 ; + r = allread(fd, tmp, lines) ; + if (r < lines && errno) return 0 ; lines -= byte_count(tmp, r, '\n') ; if (buffer_put(buffer_1, tmp, r) < (ssize_t)r) return 0 ; } |