summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Pavlik <rpavlik@iastate.edu>2012-04-20 13:46:21 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-11-28 14:39:00 +0000
commit8e2bac0a69173b51e17a39d70e1d154b47fd0139 (patch)
tree2c09a9e69fe9c5e96872bd654d70ad84de53c1bd
parent6a6c3afe71ac82a93d9fd0034dd5bbdcf0eae1ea (diff)
os/osinit.c, os/utils.c: Exclude sigaction code when building for MinGW
MinGW doesn't have sigaction, so this patch is needed for building. No attempt is made to actually install the fatal error signal handler, as MinGW will simply terminate the process rather than deliver a fatal signal. Also avoid using strsignal Signed-off-by: Ryan Pavlik <rpavlik@iastate.edu> Reviewed-by: Jon TURNEY <jon.turney@dronecode.org.uk> Tested-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--os/osinit.c5
-rw-r--r--os/utils.c4
2 files changed, 9 insertions, 0 deletions
diff --git a/os/osinit.c b/os/osinit.c
index 45ab5271b..2a946a456 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -102,6 +102,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
* OsSigHandler --
* Catch unexpected signals and exit or continue cleanly.
*/
+#if !defined(WIN32) || defined(__CYGWIN__)
static void
#ifdef SA_SIGINFO
OsSigHandler(int signo, siginfo_t * sip, void *unused)
@@ -146,6 +147,7 @@ OsSigHandler(int signo)
FatalError("Caught signal %d (%s). Server aborting\n",
signo, strsignal(signo));
}
+#endif /* !WIN32 || __CYGWIN__ */
void
OsInit(void)
@@ -155,6 +157,7 @@ OsInit(void)
char fname[PATH_MAX];
if (!been_here) {
+#if !defined(WIN32) || defined(__CYGWIN__)
struct sigaction act, oact;
int i;
@@ -181,6 +184,8 @@ OsInit(void)
siglist[i], strerror(errno));
}
}
+#endif /* !WIN32 || __CYGWIN__ */
+
#ifdef HAVE_BACKTRACE
/*
* initialize the backtracer, since the ctor calls dlopen(), which
diff --git a/os/utils.c b/os/utils.c
index 3c520add5..58df70902 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -212,6 +212,9 @@ sig_atomic_t inSignalContext = FALSE;
OsSigHandlerPtr
OsSignal(int sig, OsSigHandlerPtr handler)
{
+#if defined(WIN32) && !defined(__CYGWIN__)
+ return signal(sig, handler);
+#else
struct sigaction act, oact;
sigemptyset(&act.sa_mask);
@@ -222,6 +225,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
if (sigaction(sig, &act, &oact))
perror("sigaction");
return oact.sa_handler;
+#endif
}
/*