From ae920f77a0fc2141e3391dd2eb869e33509939bb Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 27 Mar 2015 17:35:39 +0000 Subject: [PATCH] PR/438: Deal with lack of sig_t on illumos/solaris. --- configure.ac | 6 +++++- src/compress.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b65e866f..581baa80 100644 --- a/configure.ac +++ b/configure.ac @@ -82,9 +82,13 @@ AC_HEADER_MAJOR AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h) AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h) -AC_CHECK_HEADERS(getopt.h err.h xlocale.h) +AC_CHECK_HEADERS(getopt.h err.h xlocale.h signal.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h) AC_CHECK_HEADERS(zlib.h) +AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[ +#ifdef HAVE_SIGNAL_H +#include +#endif]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/src/compress.c b/src/compress.c index 207c4c19..5eda5403 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.78 2015/01/02 21:29:39 christos Exp $") #endif #include "magic.h" @@ -45,7 +45,12 @@ FILE_RCSID("@(#)$File: compress.c,v 1.77 2014/12/12 16:33:01 christos Exp $") #endif #include #include +#ifdef HAVE_SIGNAL_H #include +# ifndef HAVE_SIG_T +typedef void (*sig_t)(int); +# endif /* HAVE_SIG_T */ +#endif #if !defined(__MINGW32__) && !defined(WIN32) #include #endif @@ -104,12 +109,16 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, size_t i, nsz; int rv = 0; int mime = ms->flags & MAGIC_MIME; +#ifdef HAVE_SIGNAL_H sig_t osigpipe; +#endif if ((ms->flags & MAGIC_COMPRESS) == 0) return 0; +#ifdef HAVE_SIGNAL_H osigpipe = signal(SIGPIPE, SIG_IGN); +#endif for (i = 0; i < ncompr; i++) { if (nbytes < compr[i].maglen) continue; @@ -136,7 +145,9 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, } } error: +#ifdef HAVE_SIGNAL_H (void)signal(SIGPIPE, osigpipe); +#endif free(newbuf); ms->flags |= MAGIC_COMPRESS; return rv; -- 2.40.0