]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
- patch from Martin Pool to setup an uncached file descriptor for
authorAndrew Tridgell <tridge@samba.org>
Wed, 24 Sep 2003 07:26:15 +0000 (09:26 +0200)
committerAndrew Tridgell <tridge@samba.org>
Wed, 24 Sep 2003 07:26:15 +0000 (09:26 +0200)
stderr

ccache.c

index 514bcf8c39acb6a415a9c095a3523640291ce34c..b9d91421f5de3f0fa08d9ffa1d02dbe9f163fa72 100644 (file)
--- 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) {