[PATCH 5/9] os/osinit.c, os/utils.c: Exclude sigaction code when X_NOT_POSIX

Jon TURNEY jon.turney at dronecode.org.uk
Wed Jan 11 12:13:25 PST 2012


From: Ryan Pavlik <rpavlik at iastate.edu>

In particular, 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 terminate the process rather than deliver a fatal signal.

(This is patterned after the use of X_NOT_POSIX in xhost.  It might be better to
just add an autoconf check for sigaction(), or just just WIN32)

Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 os/osinit.c |    5 +++++
 os/utils.c  |    4 ++++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/os/osinit.c b/os/osinit.c
index ff3c45d..18d099d 100644
--- a/os/osinit.c
+++ b/os/osinit.c
@@ -103,6 +103,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
  * OsSigHandler --
  *    Catch unexpected signals and exit or continue cleanly.
  */
+#ifndef X_NOT_POSIX
 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
 
 void
 OsInit(void)
@@ -155,6 +157,7 @@ OsInit(void)
     char fname[PATH_MAX];
 
     if (!been_here) {
+#ifndef X_NOT_POSIX
 	struct sigaction act, oact;
 	int i;
 	int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
@@ -199,6 +202,8 @@ OsInit(void)
 	dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
 #endif
 
+#endif /* !X_NOT_POSIX */
+
 #if !defined(__CYGWIN__) 
 	fclose(stdin);
 	fclose(stdout);
diff --git a/os/utils.c b/os/utils.c
index 6461ed5..3c07f9c 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -210,6 +210,9 @@ char *SeatId = NULL;
 OsSigHandlerPtr
 OsSignal(int sig, OsSigHandlerPtr handler)
 {
+#ifdef X_NOT_POSIX
+    return signal(sig, handler);
+#else
     struct sigaction act, oact;
 
     sigemptyset(&act.sa_mask);
@@ -220,6 +223,7 @@ OsSignal(int sig, OsSigHandlerPtr handler)
     if (sigaction(sig, &act, &oact))
       perror("sigaction");
     return oact.sa_handler;
+#endif
 }
 
 /*
-- 
1.7.5.1



More information about the xorg-devel mailing list