From 6827d8ff8e7c4e2003c6065d1769c780b4f96973 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 19 Feb 2011 17:35:32 -0400 Subject: pee: Propigate exit status of commands run. --- pee.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'pee.c') diff --git a/pee.c b/pee.c index 6ba38f7..cd3ff20 100644 --- a/pee.c +++ b/pee.c @@ -1,5 +1,7 @@ #include #include +#include +#include /* Licensed under the GPL * Copyright (c) Miek Gieben, 2006 @@ -9,12 +11,19 @@ * pipes _and_ output to standard output */ -void +int close_pipes(FILE **p, size_t i) { + int ret=EXIT_SUCCESS; size_t j; - for (j = 0; j < i; j++) - pclose(p[j]); + for (j = 0; j < i; j++) { + int r = pclose(p[j]); + if (WIFEXITED(r)) + ret |= WEXITSTATUS(r); + else + ret |= 1; + } + return ret; } int @@ -48,7 +57,5 @@ main(int argc, char **argv) { } } } - close_pipes(pipes, argc); - - exit(EXIT_SUCCESS); + exit(close_pipes(pipes, argc)); } -- cgit v1.2.1