@@ -73,6 +73,17 @@
AC_TYPE_SSIZE_T
AC_TYPE_UINT32_T
+AC_CHECK_TYPE([sig_atomic_t],,AC_DEFINE_UNQUOTED([sig_atomic_t],int,[Define atomic signal type]),[
+AC_INCLUDES_DEFAULT
+#include <signal.h>
+])
+
+AC_CHECK_TYPE([sigset_t],,AC_DEFINE_UNQUOTED([sigset_t],int,[Define type for signal mask, may be int where signal blocking is not supported at all]),[
+AC_INCLUDES_DEFAULT
+#include <signal.h>
+])
+
+
AC_CHECK_TYPE([intmax_t],,AC_DEFINE_UNQUOTED([intmax_t],long,[Define intmax_t type, must also be supported by printf]))
AC_CHECK_TYPE([uintmax_t],,AC_DEFINE_UNQUOTED([uintmax_t],unsigned long,[Define uintmax_t type, must also be supported by printf]))
@@ -106,7 +117,7 @@
mempcpy memmove \
sigsetmask stpcpy strchrnul strsignal strtod strtoimax \
strtoumax sysconf \
- vfork lstat dup2 getgroups \
+ vfork sigaction sigprocmask lstat dup2 getgroups \
strstr stpncpy strcasecmp strerror strdup strtoul vsnprintf \
readdir)
@@ -48,9 +48,11 @@
#pragma GCC diagnostic pop
#endif
#else
+# ifdef HAVE_SIGPROCMASK
sigset_t set;
sigemptyset(&set);
sigprocmask(SIG_SETMASK, &set, 0);
+# endif
#endif
}
@@ -181,7 +181,16 @@
int action;
int lvforked;
char *t, tsig;
+#ifdef HAVE_SIGACTION
struct sigaction act;
+#define SIGNAL(signo) sigaction(signo, &act,0)
+#define HDLR act.sa_handler
+#else
+ typedef void (*sighandler_t)(int);
+ sighandler_t hdlr;
+#define SIGNAL(signo) signal(signo, hdlr)
+#define HDLR hdlr
+#endif
lvforked = vforked;
@@ -222,6 +231,7 @@
t = &sigmode[signo - 1];
tsig = *t;
+#ifdef HAVE_SIGACTION
if (tsig == 0) {
/*
* current setting unknown
@@ -244,23 +254,28 @@
tsig = S_RESET; /* force to be set */
}
}
- if (tsig == S_HARD_IGN || tsig == action)
+ if (tsig == action)
+ return;
+#endif
+ if (tsig == S_HARD_IGN)
return;
switch (action) {
case S_CATCH:
- act.sa_handler = onsig;
+ HDLR = onsig;
break;
case S_IGN:
- act.sa_handler = SIG_IGN;
+ HDLR = SIG_IGN;
break;
default:
- act.sa_handler = SIG_DFL;
+ HDLR = SIG_DFL;
}
if (!lvforked)
*t = action;
+#ifdef HAVE_SIGACTION
act.sa_flags = 0;
sigfillset(&act.sa_mask);
- sigaction(signo, &act, 0);
+#endif
+ SIGNAL(signo);
}
/*
@@ -286,6 +301,9 @@
void
onsig(int signo)
{
+#ifndef HAVE_SIGACTION
+ signal(signo, onsig);
+#endif
if (vforked)
return;
@@ -441,8 +459,13 @@
void sigblockall(sigset_t *oldmask)
{
+#ifdef HAVE_SIGPROCMASK
sigset_t mask;
sigfillset(&mask);
sigprocmask(SIG_SETMASK, &mask, oldmask);
+#else
+ if(oldmask)
+ *oldmask = 0;
+#endif
}