rpm/0001-Support-running-rpmfcExec-without-any-piped-input-ou.patch

52 lines
1.5 KiB
Diff

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