From 8fdd042394b7395c13bee66afb45dd3875c60c63 Mon Sep 17 00:00:00 2001 From: graham.gower Date: Thu, 26 Nov 2009 20:22:10 -0500 Subject: 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 --- (limited to 'libbb/unzip.c') 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 #include #include +#include #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; -- cgit v0.9.1