summaryrefslogtreecommitdiffstats
path: root/libbb/unzip.c
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-26 20:22:10 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-26 20:22:10 (EST)
commit8fdd042394b7395c13bee66afb45dd3875c60c63 (patch)
treeee7ce27b3b440710d4f0b82e6e14fe0e483eb71e /libbb/unzip.c
parent6afed21188df0c417349563621302ec85f44096f (diff)
Check the unzip child process for errors and pass the upwards. Also, avoid child from being killed by SIGPIPE.
git-svn-id: http://opkg.googlecode.com/svn/trunk@392 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libbb/unzip.c')
-rw-r--r--libbb/unzip.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libbb/unzip.c b/libbb/unzip.c
index 186da59..7ff07a5 100644
--- a/libbb/unzip.c
+++ b/libbb/unzip.c
@@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "libbb.h"
static FILE *in_file, *out_file;
@@ -149,6 +150,14 @@ static void flush_window(void)
}
if (fwrite(window, 1, outcnt, out_file) != outcnt) {
+ /*
+ * The Parent process may not be interested in all the data we have,
+ * in which case it will rudely close its end of the pipe and
+ * wait for us to exit.
+ */
+ if (errno == EPIPE)
+ _exit(EXIT_SUCCESS);
+
error_msg("Couldnt write");
_exit(EXIT_FAILURE);
}
@@ -917,6 +926,8 @@ extern int unzip(FILE *l_in_file, FILE *l_out_file)
}
#endif
+ signal(SIGPIPE, SIG_IGN);
+
/* Allocate all global buffers (for DYN_ALLOC option) */
window = xmalloc((size_t)(((2L*WSIZE)+1L)*sizeof(unsigned char)));
outcnt = 0;