From 43dde3b628331bf43cacc93e85c676ffa9a76e2f Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 18 Jul 2022 12:57:53 +0000 Subject: Fix allread errno management Signed-off-by: Laurent Bercot --- src/skaembutils/s6-head.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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 #include #include + #include #include #include @@ -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 ; } -- cgit v1.2.3