diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2011-09-05 08:38:31 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2011-09-05 08:38:31 +0300 |
commit | 75cea7a534ebe97d1c8d7345d469112f891bb7e8 (patch) | |
tree | e14ab0d2384b5f813653a9e152c4a66ff2798ebc | |
parent | 0b57571990817fa9872b9adfb000930bb09d58c0 (diff) | |
download | rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.tar.gz rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.tar.bz2 rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.zip |
Make --pipe command failures reflect our exit codes (RhBug:735481)
-rw-r--r-- | cliutils.c | 16 | ||||
-rw-r--r-- | cliutils.h | 2 | ||||
-rw-r--r-- | rpmbuild.c | 3 | ||||
-rw-r--r-- | rpmqv.c | 3 | ||||
-rw-r--r-- | rpmspec.c | 3 |
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); @@ -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); @@ -110,7 +110,8 @@ int main(int argc, char *argv[]) } rpmtsFree(ts); - finishPipe(); + if (finishPipe()) + ec = EXIT_FAILURE; free(qva->qva_queryFormat); |