From 780d862e2abfae5635cd963304cd1e635a553fa7 Mon Sep 17 00:00:00 2001 From: Jan Filip Chadima Date: Tue, 25 Feb 2020 16:15:42 +0100 Subject: [PATCH] io-careful: Do not fail if a system call is interrupted by a signal --- ucw/io-careful.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; -- 2.39.2