From 1523ce64c0677a44939ec49343fa04c94b6e2cda Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Sun, 19 Jul 2020 20:47:55 +0200 Subject: [PATCH] Handle EINTR properly in Result::Writer::write_embedded_file_entry --- src/Result.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Result.cpp b/src/Result.cpp index 375e911e2..68e5771ae 100644 --- a/src/Result.cpp +++ b/src/Result.cpp @@ -380,10 +380,14 @@ Result::Writer::write_embedded_file_entry(CacheEntryWriter& writer, uint8_t buf[READ_BUFFER_SIZE]; size_t n = std::min(remain, static_cast(sizeof(buf))); ssize_t bytes_read = read(*file, buf, n); - if (bytes_read < 1) { + if (bytes_read == -1) { + if (errno == EINTR) { + continue; + } throw Error( fmt::format("Error reading from {}: {}", path, strerror(errno))); - } else if (bytes_read == 0) { + } + if (bytes_read == 0) { throw Error(fmt::format("Error reading from {}: end of file", path)); } writer.write(buf, n); -- 2.47.3