changeset 4691:5db8a7848565

Automated merge with ssh://hg.atheme.org//hg/audacious
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 16:56:35 -0500
parents a5707f571100 (current diff) cd1e4d4aa0b9 (diff)
children 84f70d4b36e6
files
diffstat 2 files changed, 55 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Sat Jul 05 15:45:56 2008 +0200
+++ b/configure.ac	Sat Jul 05 16:56:35 2008 -0500
@@ -67,7 +67,7 @@
 dnl Check for headers and functions
 dnl ===============================
 AC_CHECK_HEADERS([unistd.h fcntl.h sys/ioctl.h fnmatch.h limits.h wchar.h fts.h execinfo.h])
-AC_CHECK_FUNCS([mkdtemp getmntinfo statvfs strtoul lrintf])
+AC_CHECK_FUNCS([mkdtemp getmntinfo statvfs strtoul lrintf signalfd])
 
 
 ### ---------------------------------------------------------------------------
--- a/src/audacious/signals.c	Sat Jul 05 15:45:56 2008 +0200
+++ b/src/audacious/signals.c	Sat Jul 05 16:56:35 2008 -0500
@@ -85,6 +85,8 @@
     abort();
 }
 
+#ifndef HAVE_SIGNALFD
+
 static void *
 signal_process_signals (void *data)
 {
@@ -172,6 +174,58 @@
     linuxthread_signal_number = signal_number;
 }
 
+#else
+
+#include <sys/signalfd.h>
+
+static gpointer
+signal_process_signals(gpointer data)
+{
+    struct signalfd_siginfo d;
+    sigset_t waitset;
+    int sigfd;
+
+    sigemptyset(&waitset);
+    sigaddset(&waitset, SIGPIPE);
+    sigaddset(&waitset, SIGSEGV);  
+    sigaddset(&waitset, SIGINT);
+    sigaddset(&waitset, SIGTERM);
+
+    sigfd = signalfd(-1, &waitset, 0);
+
+    while (read(sigfd, &d, sizeof(struct signalfd_siginfo)) > 0)
+    {
+        switch(d.ssi_signo)
+        {
+        case SIGPIPE:
+            /*
+             * do something.
+             */
+            break;
+
+        case SIGSEGV:
+            signal_process_segv();
+            break;
+
+        case SIGINT:
+            g_print("Audacious has received SIGINT and is shutting down.\n");
+            aud_quit();
+            break;
+
+        case SIGTERM:
+            g_print("Audacious has received SIGTERM and is shutting down.\n");
+            aud_quit();
+            break;
+        }
+    }
+
+    close(sigfd);
+
+    return NULL;
+}
+
+#endif
+
 static SignalHandler
 signal_install_handler_full (gint           signal_number,
                              SignalHandler  handler,