[hackers] [scc] Explicitly use stdout/stdin for pipe communication || Quentin Rameau

From: <git_AT_suckless.org>
Date: Tue, 2 Feb 2016 17:39:25 +0100 (CET)

commit f7ba49e4d1a750def40120fd78add0eda158d723
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Tue Feb 2 17:37:11 2016 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Tue Feb 2 17:37:11 2016 +0100

    Explicitly use stdout/stdin for pipe communication

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 318293f..657c313 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -41,8 +41,7 @@ cc1(int fd)
                 perror("scc:cc1");
                 exit(1);
         case 0:
- close(1);
- dup(fd);
+ dup2(fd, 1);
                 fmt = (arch) ? "%s/libexec/scc/cc1-%s" : "%s/libexec/scc/cc1";
                 r = snprintf(cmd, sizeof(cmd), fmt, PREFIX, arch);
                 if (r == sizeof(cmd)) {
_AT_@ -71,8 +70,7 @@ cc2(int fd)
                 perror("scc:cc2");
                 exit(1);
         case 0:
- close(0);
- dup(fd);
+ dup2(fd, 0);
                 fmt = (arch) ? "%s/libexec/scc/cc2-%s" : "%s/libexec/scc/cc2";
                 r = snprintf(cmd, sizeof(cmd), fmt, PREFIX, arch);
                 if (r == sizeof(cmd)) {
Received on Tue Feb 02 2016 - 17:39:25 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 02 2016 - 17:48:07 CET