Fall back on sa_handler if sa_sigaction doesn't work
authorDavid Schleef <ds@schleef.org>
Sun, 13 Apr 2003 21:11:12 +0000 (21:11 +0000)
committerDavid Schleef <ds@schleef.org>
Sun, 13 Apr 2003 21:11:12 +0000 (21:11 +0000)
Original commit message from CVS:
Fall back on sa_handler if sa_sigaction doesn't work

common
tools/gst-launch.c

diff --git a/common b/common
index 0ce4bbf..ed42933 160000 (submodule)
--- a/common
+++ b/common
@@ -1 +1 @@
-Subproject commit 0ce4bbf0bc51c08694a8a1e0bec7624094b043d6
+Subproject commit ed429334bba35b10172ba97d9b3795b75a65b388
index eba59eb..be564ad 100644 (file)
@@ -110,12 +110,38 @@ xmllaunch_parse_cmdline (const gchar **argv)
 
 extern volatile gboolean glib_on_error_halt;
 static void fault_restore(void);
+static void fault_spin (void);
 
+/* FIXME: This is just a temporary hack.  We should have a better
+ * check for siginfo handling. */
+#ifdef SA_SIGINFO
+#define USE_SIGINFO
+#endif
+
+#ifndef USE_SIGINFO
 static void 
-fault_handler (int signum, siginfo_t *si, void *misc)
+fault_handler_sighandler (int signum)
 {
-  int spinning = TRUE;
+  fault_restore ();
 
+  if (signum == SIGSEGV) {
+    g_print ("Caught SIGSEGV\n");
+  }
+  else if (signum == SIGQUIT){
+    g_print ("Caught SIGQUIT\n");
+  }
+  else {
+    g_print ("signo:  %d\n", signum);
+  }
+
+  fault_spin();
+}
+
+#else
+
+static void 
+fault_handler_sigaction (int signum, siginfo_t *si, void *misc)
+{
   fault_restore ();
 
   if (si->si_signo == SIGSEGV) {
@@ -130,6 +156,15 @@ fault_handler (int signum, siginfo_t *si, void *misc)
     g_print ("code:   %d\n", si->si_code);
   }
 
+  fault_spin();
+}
+#endif
+
+static void
+fault_spin (void)
+{
+  int spinning = TRUE;
+
   glib_on_error_halt = FALSE;
   g_on_error_stack_trace ("gst-launch");
 
@@ -151,7 +186,6 @@ fault_handler (int signum, siginfo_t *si, void *misc)
 
   _exit(0);
 #endif
-
 }
 
 static void 
@@ -172,8 +206,12 @@ fault_setup (void)
   struct sigaction action;
 
   memset (&action, 0, sizeof (action));
-  action.sa_sigaction = fault_handler;
+#ifdef USE_SIGINFO
+  action.sa_sigaction = fault_handler_sigaction;
   action.sa_flags = SA_SIGINFO;
+#else
+  action.sa_handler = fault_handler_sighandler;
+#endif
 
   sigaction (SIGSEGV, &action, NULL);
   sigaction (SIGQUIT, &action, NULL);