diff options
author | delphij <delphij@FreeBSD.org> | 2015-01-02 21:20:02 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-01-02 21:20:02 +0000 |
commit | 1bda30591aca9572e7da640b3af5447296f6d005 (patch) | |
tree | f4ff57ef01d3be17382b5421746e088c6954eeda /contrib/file/src/compress.c | |
parent | 2ea8fb0629743808332e7dce5b26fd8deb275d99 (diff) | |
parent | f243c198ffedd6408e117b77e39a5a6277aa57b2 (diff) | |
download | FreeBSD-src-1bda30591aca9572e7da640b3af5447296f6d005.zip FreeBSD-src-1bda30591aca9572e7da640b3af5447296f6d005.tar.gz |
MFV r276568:
Update file to 5.22.
MFC after: 2 weeks
Diffstat (limited to 'contrib/file/src/compress.c')
-rw-r--r-- | contrib/file/src/compress.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/contrib/file/src/compress.c b/contrib/file/src/compress.c index 4a6f42e..e968bb4 100644 --- a/contrib/file/src/compress.c +++ b/contrib/file/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.75 2014/12/04 15:56:46 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $") #endif #include "magic.h" @@ -45,6 +45,7 @@ FILE_RCSID("@(#)$File: compress.c,v 1.75 2014/12/04 15:56:46 christos Exp $") #endif #include <string.h> #include <errno.h> +#include <signal.h> #if !defined(__MINGW32__) && !defined(WIN32) #include <sys/ioctl.h> #endif @@ -103,10 +104,12 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, size_t i, nsz; int rv = 0; int mime = ms->flags & MAGIC_MIME; + sig_t osigpipe; if ((ms->flags & MAGIC_COMPRESS) == 0) return 0; + osigpipe = signal(SIGPIPE, SIG_IGN); for (i = 0; i < ncompr; i++) { if (nbytes < compr[i].maglen) continue; @@ -133,6 +136,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, } } error: + (void)signal(SIGPIPE, osigpipe); free(newbuf); ms->flags |= MAGIC_COMPRESS; return rv; @@ -508,11 +512,16 @@ err: strerror(errno)); #endif n = NODATA; - } else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + } else if (!WIFEXITED(status)) { #ifdef DEBUG - (void)fprintf(stderr, "Child status (0x%x)\n", status); + (void)fprintf(stderr, "Child not exited (0x%x)\n", + status); +#endif + } else if (WEXITSTATUS(status) != 0) { +#ifdef DEBUG + (void)fprintf(stderr, "Child exited (0x%d)\n", + WEXITSTATUS(status)); #endif - n = NODATA; } (void) close(fdin[0]); |