changeset 2666:78a8b3095274 trunk

[svn] - do not use the signal handler at all on linuxthreads and hope for the best
author nenolod
date Tue, 10 Apr 2007 09:45:30 -0700
parents 9b08d6cc7e81
children 8c56926de2ad
files ChangeLog src/audacious/build_stamp.c src/audacious/signals.c
diffstat 3 files changed, 42 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Apr 10 08:42:11 2007 -0700
+++ b/ChangeLog	Tue Apr 10 09:45:30 2007 -0700
@@ -1,3 +1,11 @@
+2007-04-10 15:42:11 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [4356]
+  - include missing header
+  
+  trunk/src/audacious/signals.c |    1 +
+  1 file changed, 1 insertion(+)
+
+
 2007-04-10 15:39:56 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [4354]
   - handle sigwait(2) brokenness on linuxthreads
--- a/src/audacious/build_stamp.c	Tue Apr 10 08:42:11 2007 -0700
+++ b/src/audacious/build_stamp.c	Tue Apr 10 09:45:30 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070410-4354";
+const gchar *svn_stamp = "20070410-4356";
--- a/src/audacious/signals.c	Tue Apr 10 08:42:11 2007 -0700
+++ b/src/audacious/signals.c	Tue Apr 10 09:45:30 2007 -0700
@@ -17,6 +17,9 @@
  * 02110-1301, USA.
  */
 
+#define _XOPEN_SOURCE
+#include <unistd.h>	/* for signal_check_for_broken_impl() */
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib/gprintf.h>
@@ -25,7 +28,8 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <signal.h>
-#include <pthread.h>
+#include <pthread.h>	/* for pthread_sigmask() */
+#include <strings.h>
 
 #ifdef HAVE_EXECINFO_H
 # include <execinfo.h>
@@ -122,6 +126,9 @@
 /* sets up blocking signals for pthreads. 
  * linuxthreads sucks and needs this to make sigwait(2) work 
  * correctly. --nenolod
+ *
+ * correction -- this trick does not work on linuxthreads.
+ * going to keep it in it's own function though --nenolod
  */
 static void
 signal_initialize_blockers(void)
@@ -138,11 +145,31 @@
         g_print("pthread_sigmask() failed.\n");    
 }
 
-void 
-signal_handlers_init (void)
+static gboolean
+signal_check_for_broken_impl(void)
 {
-    signal_initialize_blockers();
-    pthread_atfork(NULL, NULL, signal_initialize_blockers);
+#ifdef _CS_GNU_LIBPTHREAD_VERSION
+    {
+        gchar str[1024];
+        confstr(_CS_GNU_LIBPTHREAD_VERSION, str, sizeof(str));
+
+        if (!strncasecmp("linuxthreads", str, 12))
+            return TRUE;
+    }
+#endif
+
+    return FALSE;
+}
 
-    g_thread_create(signal_process_signals, NULL, FALSE, NULL);
+void 
+signal_handlers_init(void)
+{
+    if (signal_check_for_broken_impl() != TRUE)
+    {
+        signal_initialize_blockers();
+        g_thread_create(signal_process_signals, NULL, FALSE, NULL);
+    }
+    else
+        g_printerr(_("Your signaling implementation is broken.\n"
+		     "Expect unusable crash reports.\n"));
 }