summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-09-05 08:38:31 +0300
committerPanu Matilainen <pmatilai@redhat.com>2011-09-05 08:38:31 +0300
commit75cea7a534ebe97d1c8d7345d469112f891bb7e8 (patch)
treee14ab0d2384b5f813653a9e152c4a66ff2798ebc
parent0b57571990817fa9872b9adfb000930bb09d58c0 (diff)
downloadrpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.tar.gz
rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.tar.bz2
rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.zip
Make --pipe command failures reflect our exit codes (RhBug:735481)
-rw-r--r--cliutils.c16
-rw-r--r--cliutils.h2
-rw-r--r--rpmbuild.c3
-rw-r--r--rpmqv.c3
-rw-r--r--rpmspec.c3
5 files changed, 20 insertions, 7 deletions
diff --git a/cliutils.c b/cliutils.c
index cbbc7fef2..5edecc51e 100644
--- a/cliutils.c
+++ b/cliutils.c
@@ -2,6 +2,7 @@
#if HAVE_MCHECK_H
#include <mcheck.h>
#endif
+#include <errno.h>
#include <sys/wait.h>
#include <rpm/rpmlog.h>
@@ -69,11 +70,20 @@ int initPipe(void)
return 0;
}
-void finishPipe(void)
+int finishPipe(void)
{
- int status;
+ int rc = 0;
if (pipeChild) {
+ int status;
+ pid_t reaped;
+
(void) fclose(stdout);
- (void) waitpid(pipeChild, &status, 0);
+ do {
+ reaped = waitpid(pipeChild, &status, 0);
+ } while (reaped == -1 && errno == EINTR);
+
+ if (reaped == -1 || !WIFEXITED(status) || WEXITSTATUS(status))
+ rc = 1;
}
+ return rc;
}
diff --git a/cliutils.h b/cliutils.h
index 875b9507c..35aa25285 100644
--- a/cliutils.h
+++ b/cliutils.h
@@ -15,6 +15,6 @@ void printUsage(poptContext con, FILE * fp, int flags);
int initPipe(void);
-void finishPipe(void);
+int finishPipe(void);
#endif /* _CLIUTIL_H */
diff --git a/rpmbuild.c b/rpmbuild.c
index c51aa36e1..a338c3c36 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -628,7 +628,8 @@ int main(int argc, char *argv[])
}
rpmtsFree(ts);
- finishPipe();
+ if (finishPipe())
+ ec = EXIT_FAILURE;
free(ba->buildRootOverride);
argvFree(build_targets);
diff --git a/rpmqv.c b/rpmqv.c
index 4841cb877..2b415e608 100644
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -333,7 +333,8 @@ int main(int argc, char *argv[])
}
rpmtsFree(ts);
- finishPipe();
+ if (finishPipe())
+ ec = EXIT_FAILURE;
#ifdef IAM_RPMQV
free(qva->qva_queryFormat);
diff --git a/rpmspec.c b/rpmspec.c
index e7606988c..f7f6962d2 100644
--- a/rpmspec.c
+++ b/rpmspec.c
@@ -110,7 +110,8 @@ int main(int argc, char *argv[])
}
rpmtsFree(ts);
- finishPipe();
+ if (finishPipe())
+ ec = EXIT_FAILURE;
free(qva->qva_queryFormat);