]> granicus.if.org Git - file/commitdiff
PR/438: Deal with lack of sig_t on illumos/solaris.
authorChristos Zoulas <christos@zoulas.com>
Fri, 27 Mar 2015 17:35:39 +0000 (17:35 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 27 Mar 2015 17:35:39 +0000 (17:35 +0000)
configure.ac
src/compress.c

index b65e866fb5a9564b79ddc9dcc769fdfd9e35bbc7..581baa803fe48f8b7b999724b39254a0ce7fbb92 100644 (file)
@@ -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 <signal.h>
+#endif])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
index 207c4c19912a38f4880b17916a9ffd2b3ef782fd..5eda5403e24d83a22a77dbd9fa38ca6efa139042 100644 (file)
@@ -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 <string.h>
 #include <errno.h>
+#ifdef HAVE_SIGNAL_H
 #include <signal.h>
+# ifndef HAVE_SIG_T
+typedef void (*sig_t)(int);
+# endif /* HAVE_SIG_T */
+#endif 
 #if !defined(__MINGW32__) && !defined(WIN32)
 #include <sys/ioctl.h>
 #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;