From: Jan Filip Chadima Date: Tue, 25 Feb 2020 15:15:42 +0000 (+0100) Subject: io-careful: Do not fail if a system call is interrupted by a signal X-Git-Tag: v6.5.12~2 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=780d862e2abfae5635cd963304cd1e635a553fa7;p=libucw.git io-careful: Do not fail if a system call is interrupted by a signal --- diff --git a/ucw/io-careful.c b/ucw/io-careful.c index a3a8a806..b679f49f 100644 --- a/ucw/io-careful.c +++ b/ucw/io-careful.c @@ -2,6 +2,7 @@ * UCW Library -- Careful Read/Write * * (c) 2004--2012 Martin Mares + * (c) 2020 Jan Filip Chadima * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -25,7 +26,11 @@ careful_read(int fd, void *buf, size_t len) { ssize_t l = read(fd, pos, len); if (l < 0) - return -1; + { + if (errno == EINTR) + continue; + return -1; + } if (!l) return 0; pos += l; @@ -42,7 +47,11 @@ careful_write(int fd, const void *buf, size_t len) { ssize_t l = write(fd, pos, len); if (l < 0) - return -1; + { + if (errno == EINTR) + continue; + return -1; + } if (!l) return 0; pos += l;