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 /cliutils.c | |
parent | 0b57571990817fa9872b9adfb000930bb09d58c0 (diff) | |
download | rpm-75cea7a534ebe97d1c8d7345d469112f891bb7e8.tar.gz |
Make --pipe command failures reflect our exit codes (RhBug:735481)
Diffstat (limited to 'cliutils.c')
-rw-r--r-- | cliutils.c | 16 |
1 files changed, 13 insertions, 3 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; } |