From 9f60e85af74ddbbbc26e06ba6621f80abc868da7 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 18 Jul 2022 12:49:05 +0000 Subject: Fix allread errno management Signed-off-by: Laurent Bercot --- src/libs6/s6_dtally_read.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/libs6/s6_dtally_read.c b/src/libs6/s6_dtally_read.c index a1623cc..fbd40b0 100644 --- a/src/libs6/s6_dtally_read.c +++ b/src/libs6/s6_dtally_read.c @@ -4,6 +4,7 @@ #include #include #include + #include #include #include @@ -19,6 +20,7 @@ static int truncit (char const *s) ssize_t s6_dtally_read (char const *sv, s6_dtally_t *tab, size_t max) { + int e = errno ; size_t len = strlen(sv) ; size_t n ; int fd ; @@ -39,10 +41,12 @@ ssize_t s6_dtally_read (char const *sv, s6_dtally_t *tab, size_t max) { char tmp[n ? S6_DTALLY_PACK * n : 1] ; if (lseek(fd, -(off_t)(n * S6_DTALLY_PACK), SEEK_END) < 0) goto err ; + errno = EPIPE ; if (allread(fd, tmp, n * S6_DTALLY_PACK) < n * S6_DTALLY_PACK) goto err ; fd_close(fd) ; for (size_t i = 0 ; i < n ; i++) s6_dtally_unpack(tmp + i * S6_DTALLY_PACK, tab + i) ; } + errno = e ; return n ; err: -- cgit v1.2.3