[hackers] [scc] [driver] Discard error messages not from cc1 || Quentin Rameau

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 23:06:58 +0100 (CET)

commit b4bedf30b77624450f8c1e9d3aafd7ab0e41075c
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Wed Feb 15 16:38:20 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
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
_AT_@ -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>
_AT_@ -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;
 
_AT_@ -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));
_AT_@ -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))
Received on Fri Feb 17 2017 - 23:06:58 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 23:12:18 CET