s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 9f60e85af74ddbbbc26e06ba6621f80abc868da7
parent cb454933082f8aa9bee6fa710666f557235abeb7
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Mon, 18 Jul 2022 12:49:05 +0000

 Fix allread errno management

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Msrc/libs6/s6_dtally_read.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git 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: