From be23d25d8ca8ebf1fad1254349d02d11db603aa7 Mon Sep 17 00:00:00 2001 From: Alfred Landrum Date: Fri, 7 Sep 2012 20:39:26 +0200 Subject: [PATCH] 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. --- util.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } -- 2.47.2