Audacious
$Id:Doxyfile42802007-03-2104:39:00Znenolod$
|
00001 /* 00002 * signals.c 00003 * Copyright 2009 John Lindgren 00004 * 00005 * This file is part of Audacious. 00006 * 00007 * Audacious is free software: you can redistribute it and/or modify it under 00008 * the terms of the GNU General Public License as published by the Free Software 00009 * Foundation, version 2 or version 3 of the License. 00010 * 00011 * Audacious is distributed in the hope that it will be useful, but WITHOUT ANY 00012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00013 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along with 00016 * Audacious. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 * The Audacious team does not consider modular code linking to Audacious or 00019 * using our public API to be a derived work. 00020 */ 00021 00022 #include <signal.h> 00023 #include <glib.h> 00024 00025 #include <libaudcore/hook.h> 00026 00027 #include "config.h" 00028 #include "main.h" 00029 00030 #ifdef HAVE_SIGWAIT 00031 static sigset_t signal_set; 00032 00033 static void * signal_thread (void * data) 00034 { 00035 int signal; 00036 00037 while (! sigwait (& signal_set, & signal)) 00038 event_queue ("quit", NULL); 00039 00040 return NULL; 00041 } 00042 #endif 00043 00044 /* Must be called before any threads are created. */ 00045 void signals_init (void) 00046 { 00047 #ifdef HAVE_SIGWAIT 00048 sigemptyset (& signal_set); 00049 sigaddset (& signal_set, SIGHUP); 00050 sigaddset (& signal_set, SIGINT); 00051 sigaddset (& signal_set, SIGQUIT); 00052 sigaddset (& signal_set, SIGTERM); 00053 00054 sigprocmask (SIG_BLOCK, & signal_set, NULL); 00055 g_thread_create (signal_thread, NULL, FALSE, NULL); 00056 #endif 00057 }