]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle EINTR correctly in copy_fd
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Jul 2020 19:01:01 +0000 (21:01 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 9 Jul 2020 19:01:01 +0000 (21:01 +0200)
src/legacy_util.cpp

index a8c6b177c4e87e1b2d7f3f71dd13236517616443..bd2bbc6b9b2dc53907b68c1543c613f463799972 100644 (file)
@@ -97,8 +97,11 @@ copy_fd(int fd_in, int fd_out)
 {
   ssize_t n;
   char buf[READ_BUFFER_SIZE];
-  while ((n = read(fd_in, buf, sizeof(buf))) > 0) {
-    if (!write_fd(fd_out, buf, n)) {
+  while ((n = read(fd_in, buf, sizeof(buf))) != 0) {
+    if (n == -1 && errno != EINTR) {
+      break;
+    }
+    if (n > 0 && !write_fd(fd_out, buf, n)) {
       return false;
     }
   }