]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Handle EAGAIN during copy_fd
authorAlfred Landrum <alfred.landrum@riverbed.com>
Fri, 7 Sep 2012 18:39:26 +0000 (20:39 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Fri, 7 Sep 2012 18:39:26 +0000 (20:39 +0200)
In util.c, write may return EAGAIN if the file descriptor is a full pipe.
Currently, if this occurs, the log message "ccache: FATAL: Failed to copy fd"
is printed and ccache exits. We've seen this locally when the recorded stderr
output was exceptionally large due to many compilation warnings.

util.c

diff --git a/util.c b/util.c
index b4898000642b6df777f8502d89846daa5a80c225..9a91d4ccf178d812d9a45ccfddfecf45eb24b5b8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -149,10 +149,13 @@ copy_fd(int fd_in, int fd_out)
                ssize_t count, written = 0;
                do {
                        count = write(fd_out, buf + written, n - written);
-                       if (count == -1 && errno != EINTR) {
-                               fatal("Failed to copy fd");
+                       if (count == -1) {
+                               if (errno != EAGAIN && errno != EINTR) {
+                                       fatal("Failed to copy fd");
+                               }
+                       } else {
+                               written += count;
                        }
-                       written += count;
                } while (written < n);
        }