summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/tar/buffer.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gnu/usr.bin/tar/buffer.c b/gnu/usr.bin/tar/buffer.c
index 992b322..11b33d4 100644
--- a/gnu/usr.bin/tar/buffer.c
+++ b/gnu/usr.bin/tar/buffer.c
@@ -1256,6 +1256,21 @@ close_archive ()
if (f_verify)
verify_volume ();
+#ifndef __MSDOS__
+ /*
+ * Closing the child's pipe before reading EOF guarantees that it
+ * will be unhappy - SIGPIPE, or exit 1.
+ * Either way it can screw us, so play nice.
+ */
+ if (childpid && ar_reading)
+ {
+ char buf[BUFSIZ];
+
+ while ((c = read(archive, buf, sizeof(buf))) > 0)
+ ;
+ }
+#endif
+
if ((c = rmtclose (archive)) < 0)
msg_perror ("Warning: can't close %s(%d,%d)", ar_files[cur_ar_file], archive, c);
@@ -1294,8 +1309,11 @@ close_archive ()
/* Do nothing. */
}
else if (WEXITSTATUS (status))
- msg ("child returned status %d",
- WEXITSTATUS (status));
+ {
+ msg ("child returned status %d",
+ WEXITSTATUS (status));
+ exit (EX_BADARCH);
+ }
}
}
}
OpenPOWER on IntegriCloud