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

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 10:52:56 +0100 (CET)

commit 9a0387c5cea028db4545fd14df5debceba03ec0a
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 10:51:12 2017 +0100

    [libc] 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 - 10:52:56 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 11:00:22 CET