Panu Matilainen c9c421
From ad4673589428db6e3b9fecd6f151eb899500336d Mon Sep 17 00:00:00 2001
Panu Matilainen c9c421
Message-Id: <ad4673589428db6e3b9fecd6f151eb899500336d.1566556207.git.pmatilai@redhat.com>
Panu Matilainen c9c421
From: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen c9c421
Date: Thu, 15 Aug 2019 14:00:43 +0300
Panu Matilainen c9c421
Subject: [PATCH 1/3] Support running rpmfcExec() without any piped
Panu Matilainen c9c421
 input/output
Panu Matilainen c9c421
Panu Matilainen c9c421
Having a function called getOutputFrom() which doesn't is a wee bit
Panu Matilainen c9c421
weird but what the hey...
Panu Matilainen c9c421
Panu Matilainen c9c421
No behavior changes here, but this is needed for the next steps.
Panu Matilainen c9c421
---
Panu Matilainen c9c421
 build/rpmfc.c | 7 ++++++-
Panu Matilainen c9c421
 1 file changed, 6 insertions(+), 1 deletion(-)
Panu Matilainen c9c421
Panu Matilainen c9c421
diff --git a/build/rpmfc.c b/build/rpmfc.c
Panu Matilainen c9c421
index 80da96f3a..94b4620d2 100644
Panu Matilainen c9c421
--- a/build/rpmfc.c
Panu Matilainen c9c421
+++ b/build/rpmfc.c
Panu Matilainen c9c421
@@ -268,8 +268,9 @@ static int getOutputFrom(ARGV_t argv,
Panu Matilainen c9c421
     int status;
Panu Matilainen c9c421
     int myerrno = 0;
Panu Matilainen c9c421
     int ret = 1; /* assume failure */
Panu Matilainen c9c421
+    int doio = (writePtr || sb_stdout || dup);
Panu Matilainen c9c421
 
Panu Matilainen c9c421
-    if (pipe(toProg) < 0 || pipe(fromProg) < 0) {
Panu Matilainen c9c421
+    if (doio && (pipe(toProg) < 0 || pipe(fromProg) < 0)) {
Panu Matilainen c9c421
 	rpmlog(RPMLOG_ERR, _("Couldn't create pipe for %s: %m\n"), argv[0]);
Panu Matilainen c9c421
 	return -1;
Panu Matilainen c9c421
     }
Panu Matilainen c9c421
@@ -303,6 +304,9 @@ static int getOutputFrom(ARGV_t argv,
Panu Matilainen c9c421
 	return -1;
Panu Matilainen c9c421
     }
Panu Matilainen c9c421
 
Panu Matilainen c9c421
+    if (!doio)
Panu Matilainen c9c421
+	goto reap;
Panu Matilainen c9c421
+
Panu Matilainen c9c421
     close(toProg[0]);
Panu Matilainen c9c421
     close(fromProg[1]);
Panu Matilainen c9c421
 
Panu Matilainen c9c421
@@ -376,6 +380,7 @@ static int getOutputFrom(ARGV_t argv,
Panu Matilainen c9c421
     if (fromProg[0] >= 0)
Panu Matilainen c9c421
 	close(fromProg[0]);
Panu Matilainen c9c421
 
Panu Matilainen c9c421
+reap:
Panu Matilainen c9c421
     /* Collect status from prog */
Panu Matilainen c9c421
     reaped = waitpid(child, &status, 0);
Panu Matilainen c9c421
     rpmlog(RPMLOG_DEBUG, "\twaitpid(%d) rc %d status %x\n",
Panu Matilainen c9c421
-- 
Panu Matilainen c9c421
2.21.0
Panu Matilainen c9c421