changeset 2486:113f75c7b0ce trunk

[svn] - make SIGTERM handler always work.
author yaz
date Wed, 07 Feb 2007 21:08:20 -0800
parents 5ce3c51d4499
children ba8c2a94262c
files ChangeLog src/audacious/build_stamp.c src/audacious/signals.c
diffstat 3 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Feb 07 18:38:48 2007 -0800
+++ b/ChangeLog	Wed Feb 07 21:08:20 2007 -0800
@@ -1,3 +1,10 @@
+2007-02-08 02:38:48 +0000  Giacomo Lozito <james@develia.org>
+  revision [3980]
+  - add window class player.Audacious to audacious player window
+  trunk/src/audacious/ui_main.c |    1 +
+  1 file changed, 1 insertion(+)
+
+
 2007-02-07 18:23:29 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [3978]
   - add some debugging assertions to this code
--- a/src/audacious/build_stamp.c	Wed Feb 07 18:38:48 2007 -0800
+++ b/src/audacious/build_stamp.c	Wed Feb 07 21:08:20 2007 -0800
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070207-3978";
+const gchar *svn_stamp = "20070208-3980";
--- a/src/audacious/signals.c	Wed Feb 07 18:38:48 2007 -0800
+++ b/src/audacious/signals.c	Wed Feb 07 21:08:20 2007 -0800
@@ -33,6 +33,9 @@
 #include "ui_main.h"
 #include "signals.h"
 
+GCond *exit_cond;
+GMutex *exit_mutex;
+
 typedef void (*SignalHandler) (gint);
 
 static SignalHandler
@@ -103,19 +106,24 @@
 sigterm_handler (gint signal_number)
 {
     cfg.terminate = TRUE;
+    g_cond_signal(exit_cond);
 }
 
-static gboolean
-signal_process_events (gpointer data)
+static void *
+signal_process_events (void *data)
 {
-    if (cfg.terminate == TRUE)
-    {
-        g_message("Audacious has received SIGTERM and is shutting down.");
-        mainwin_quit_cb();
-        return FALSE;
+    while (1) {
+        if (cfg.terminate == TRUE)
+        {
+            g_print("Audacious has received SIGTERM and is shutting down.\n");
+            mainwin_quit_cb();
+        }
+        g_mutex_lock(exit_mutex);
+        g_cond_wait(exit_cond, exit_mutex);
+        g_mutex_unlock(exit_mutex);
     }
 
-    return TRUE;
+    return NULL;
 }
 
 void 
@@ -124,6 +132,9 @@
     char *magic;
     magic = getenv("AUD_ENSURE_BACKTRACE");
 
+    exit_cond = g_cond_new();
+    exit_mutex = g_mutex_new();
+
     signal_install_handler(SIGPIPE, signal_empty_handler);
     signal_install_handler(SIGINT, sigterm_handler);
     signal_install_handler(SIGTERM, sigterm_handler);
@@ -133,5 +144,6 @@
     if (magic == NULL)
         signal_install_handler(SIGSEGV, sigsegv_handler);
 
-    g_timeout_add(100, signal_process_events, NULL);
+    g_thread_create(signal_process_events, NULL, FALSE, NULL);
+
 }