commit b4bedf30b77624450f8c1e9d3aafd7ab0e41075c
Author:     Quentin Rameau <[email protected]>
AuthorDate: Wed Feb 15 16:38:20 2017 +0100
Commit:     Quentin Rameau <[email protected]>
CommitDate: Fri Feb 17 22:51:32 2017 +0100

    [driver] Discard error messages not from cc1

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index adfeb02..f53cc4c 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -7,6 +7,7 @@ static char sccsid[] = "@(#) ./driver/posix/scc.c";
 #include <unistd.h>
 
 #include <errno.h>
+#include <fcntl.h>
 #include <limits.h>
 #include <signal.h>
 #include <stdio.h>
@@ -55,6 +56,7 @@ static char *tmpdir;
 static size_t tmpdirln;
 static struct items objtmp, objout;
 static int Mflag, Eflag, Sflag, cflag, kflag, sflag;
+static int devnullfd;
 
 extern int failure;
 
@@ -246,6 +248,8 @@ spawn(int tool)
                        dup2(t->out, 1);
                if (t->in > -1)
                        dup2(t->in, 0);
+               if (tool != CC1)
+                       dup2(devnullfd, 2);
                execvp(t->cmd, t->args.s);
                fprintf(stderr, "scc: execvp %s: %s\n",
                        t->cmd, strerror(errno));
@@ -507,6 +511,9 @@ operand:
                tmpdir = ".";
        tmpdirln = strlen(tmpdir);
 
+       if ((devnullfd = open("/dev/null", O_WRONLY)) < 0)
+               fputs("scc: could not open /dev/null\n", stderr);
+
        build(&linkchain, (link = !(Mflag || Eflag || Sflag || cflag)));
 
        if (!(link || cflag))

Reply via email to