X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=055746188cd55b029d2026deb4ece99a17d148bb;hb=0d8e3249123ecf0175b60c7b43056ac811eb6921;hp=583edc90ea6f549e883186d097f10c496a97bd8e;hpb=cef4d5e83830763a1acd5d603fb62a356df27299;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index 583edc9..0557461 100644 --- a/src/tar.c +++ b/src/tar.c @@ -2577,7 +2577,7 @@ main (int argc, char **argv) if (stdlis == stdout) close_stdout (); else if (ferror (stderr) || fclose (stderr) != 0) - exit_status = TAREXIT_FAILURE; + set_exit_status (TAREXIT_FAILURE); return exit_status; } @@ -2615,3 +2615,13 @@ tar_timespec_cmp (struct timespec a, struct timespec b) a.tv_nsec = b.tv_nsec = 0; return timespec_cmp (a, b); } + +/* Set tar exit status to VAL, unless it is already indicating + a more serious condition. This relies on the fact that the + values of TAREXIT_ constants are ranged by severity. */ +void +set_exit_status (int val) +{ + if (val > exit_status) + exit_status = val; +}