From 6fa664e048bd225a80515aecc5f3e6275569121d Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 5 Nov 2011 19:34:57 -0400 Subject: Mask SIGPIPE for libarchive test, tar, and cpio. As reported at: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=641265 The SIGPIPE occurs when feeding data through a decompression program; the external program may see an end-of-data marker and exit before we've finished feeding it all of the data. (This happens when the data has garbage padding at the end.) We want to catch and ignore the EPIPE since we can still read the data coming out of the decompression program. SVN-Revision: 3751 --- cpio/cpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cpio/cpio.c') diff --git a/cpio/cpio.c b/cpio/cpio.c index 6a09412c..ff5a1c60 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -56,6 +56,9 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/cpio.c,v 1.15 2008/12/06 07:30:40 kientzle #ifdef HAVE_PWD_H #include #endif +#ifdef HAVE_SIGNAL_H +#include +#endif #ifdef HAVE_STDARG_H #include #endif @@ -136,6 +139,16 @@ main(int argc, char *argv[]) cpio->buff = buff; cpio->buff_size = sizeof(buff); +#if defined(HAVE_SIGACTION) && defined(SIGPIPE) + { /* Ignore SIGPIPE signals. */ + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sa.sa_handler = SIG_IGN; + sigaction(SIGPIPE, &sa, NULL); + } +#endif + /* Need lafe_progname before calling lafe_warnc. */ if (*argv == NULL) lafe_progname = "bsdcpio"; -- cgit v1.2.1