summaryrefslogtreecommitdiff
path: root/rpmqv.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-08-20 13:47:05 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-08-20 13:52:47 +0300
commit2c2faa299e6c1f2a9b6f8220c75cf878d4e005b0 (patch)
tree0c8aaf9202d523a61de95b3f623b76e1ad1adf84 /rpmqv.c
parentd391d5ec60c9fadb10236b8af236ac4b130cd2bd (diff)
downloadrpm-2c2faa299e6c1f2a9b6f8220c75cf878d4e005b0.tar.gz
rpm-2c2faa299e6c1f2a9b6f8220c75cf878d4e005b0.tar.bz2
rpm-2c2faa299e6c1f2a9b6f8220c75cf878d4e005b0.zip
Move --pipe handling to cliutils helpers
Diffstat (limited to 'rpmqv.c')
-rw-r--r--rpmqv.c32
1 files changed, 3 insertions, 29 deletions
diff --git a/rpmqv.c b/rpmqv.c
index 87d4b7577..f63e015ca 100644
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -3,7 +3,6 @@ const char *__progname;
#define _AUTOHELP
-#include <sys/wait.h>
#include <rpm/rpmcli.h>
#include <rpm/rpmlib.h> /* RPMSIGTAG, rpmReadPackageFile .. */
#include <rpm/rpmbuild.h>
@@ -118,11 +117,8 @@ int main(int argc, char *argv[])
char * passPhrase = "";
#endif
- pid_t pipeChild = 0;
poptContext optCon;
int ec = 0;
- int status;
- int p[2];
#ifdef IAM_RPMEIU
int i;
#endif
@@ -403,25 +399,8 @@ int main(int argc, char *argv[])
}
#endif /* IAM_RPMK */
- if (rpmcliPipeOutput) {
- if (pipe(p) < 0) {
- fprintf(stderr, _("creating a pipe for --pipe failed: %m\n"));
- goto exit;
- }
-
- if (!(pipeChild = fork())) {
- (void) signal(SIGPIPE, SIG_DFL);
- (void) close(p[1]);
- (void) dup2(p[0], STDIN_FILENO);
- (void) close(p[0]);
- (void) execl("/bin/sh", "/bin/sh", "-c", rpmcliPipeOutput, NULL);
- fprintf(stderr, _("exec failed\n"));
- }
-
- (void) close(p[0]);
- (void) dup2(p[1], STDOUT_FILENO);
- (void) close(p[1]);
- }
+ if (rpmcliPipeOutput && initPipe())
+ exit(EXIT_FAILURE);
ts = rpmtsCreate();
(void) rpmtsSetRootDir(ts, rpmcliRootDir);
@@ -554,13 +533,8 @@ int main(int argc, char *argv[])
}
exit:
-
ts = rpmtsFree(ts);
-
- if (pipeChild) {
- (void) fclose(stdout);
- (void) waitpid(pipeChild, &status, 0);
- }
+ finishPipe();
#ifdef IAM_RPMQV
qva->qva_queryFormat = _free(qva->qva_queryFormat);