summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-07-18 12:49:05 +0000
committerLaurent Bercot <ska@appnovation.com>2022-07-18 12:49:05 +0000
commit9f60e85af74ddbbbc26e06ba6621f80abc868da7 (patch)
tree86857373eb39c28e68cd3937435712412198af7a
parentcb454933082f8aa9bee6fa710666f557235abeb7 (diff)
downloads6-9f60e85af74ddbbbc26e06ba6621f80abc868da7.tar.xz
Fix allread errno management
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/libs6/s6_dtally_read.c4
1 files changed, 4 insertions, 0 deletions
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 <string.h>
#include <unistd.h>
#include <errno.h>
+
#include <skalibs/allreadwrite.h>
#include <skalibs/tai.h>
#include <skalibs/djbunix.h>
@@ -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: