From: Alfred Landrum Date: Fri, 7 Sep 2012 18:39:26 +0000 (+0200) Subject: Handle EAGAIN during copy_fd X-Git-Tag: v3.1.9~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be23d25d8ca8ebf1fad1254349d02d11db603aa7;p=thirdparty%2Fccache.git Handle EAGAIN during copy_fd 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. --- diff --git a/util.c b/util.c index b48980006..9a91d4ccf 100644 --- 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); }