From: Andrew Tridgell Date: Wed, 24 Sep 2003 07:26:15 +0000 (+0200) Subject: - patch from Martin Pool to setup an uncached file descriptor for X-Git-Tag: v2.3~13 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91abe457dec79972d9d1ddb20870f176e33d52e4;p=thirdparty%2Fccache.git - patch from Martin Pool to setup an uncached file descriptor for stderr --- diff --git a/ccache.c b/ccache.c index 514bcf8c3..b9d91421f 100644 --- a/ccache.c +++ b/ccache.c @@ -895,6 +895,32 @@ static int ccache_main(int argc, char *argv[]) return 0; } + +/* Make a copy of stderr that will not be cached, so things like + * distcc can send networking errors to it. */ +int setup_uncached_err(void) +{ + char *buf; + int uncached_fd; + + uncached_fd = dup(2); + if (uncached_fd == -1) { + cc_log("dup(2) failed\n"); + failed(); + } + + /* leak a pointer to the environment */ + x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd); + + if (putenv(buf) == -1) { + cc_log("putenv failed\n"); + failed(); + } + + return 0; +} + + int main(int argc, char *argv[]) { cache_dir = getenv("CCACHE_DIR"); @@ -904,6 +930,8 @@ int main(int argc, char *argv[]) cache_logfile = getenv("CCACHE_LOGFILE"); + setup_uncached_err(); + /* check if we are being invoked as "ccache" */ if (strlen(argv[0]) >= strlen(MYNAME) && strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) {