Mercurial > audlegacy
annotate src/audacious/signals.c @ 4700:3a56d2786063
move all files belonging to the legacy UI to legacy/
author | mf0102 <0102@gmx.at> |
---|---|
date | Sun, 06 Jul 2008 17:55:40 +0200 |
parents | 463675303b6f |
children | 804a026057d7 b6ec9d345b14 |
rev | line source |
---|---|
2313 | 1 /* |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
2 * Audacious |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
3 * Copyright (c) 2005-2007 Yoshiki Yazawa |
2313 | 4 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2892
diff
changeset
|
7 * the Free Software Foundation; under version 3 of the License. |
2313 | 8 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
12 * GNU General Public License for more details. |
2313 | 13 * |
2892
2f5e02538dfa
Backed out changeset 06858ea4b9d01dab0ce54891221bd1534a9c5ade
William Pitcock <nenolod@atheme.org>
parents:
2863
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
2892
diff
changeset
|
15 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
16 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * Audacious or using our public API to be a derived work. |
2313 | 19 */ |
20 | |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
21 //#define _XOPEN_SOURCE |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
22 #include <unistd.h> /* for signal_check_for_broken_impl() */ |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
23 |
2313 | 24 #include <glib.h> |
25 #include <glib/gi18n.h> | |
26 #include <config.h> | |
27 #include <stdlib.h> | |
2674
f3ee0b78150a
[svn] - use pthread_sigmask(SIG_BLOCK, ...) instead of of SIG_SETMASK
nenolod
parents:
2666
diff
changeset
|
28 #include <pthread.h> /* for pthread_sigmask() */ |
2313 | 29 #include <signal.h> |
30 | |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
31 #ifdef HAVE_EXECINFO_H |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
32 # include <execinfo.h> |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
33 #endif |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
34 |
2313 | 35 #include "main.h" |
36 #include "signals.h" | |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
37 #include "build_stamp.h" |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
38 #ifdef USE_EGGSM |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
39 #include "eggsmclient.h" |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
40 #endif |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
41 |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
42 gint linuxthread_signal_number = 0; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
43 |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
44 static void |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
45 signal_process_segv(void) |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
46 { |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
47 g_printerr(_("\nAudacious has caught signal 11 (SIGSEGV).\n\n" |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
48 "We apologize for the inconvenience, but Audacious has crashed.\n" |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
49 "This is a bug in the program, and should never happen under normal circumstances.\n" |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
50 "Your current configuration has been saved and should not be damaged.\n\n" |
4431
6456eadfe0ca
Updated bugtracker URL and made the sig11 handler tiny bit more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
4412
diff
changeset
|
51 "You can help improve the quality of Audacious by filing a bug at http://bugzilla.atheme.org/\n" |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
52 "Please include the entire text of this message and a description of what you were doing when\n" |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
53 "this crash occured in order to quickly expedite the handling of your bug report:\n\n")); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
54 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
55 g_printerr("Program version: Audacious %s (buildid: %s)\n\n", VERSION, svn_stamp); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
56 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
57 #ifdef HAVE_EXECINFO_H |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
58 { |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
59 void *stack[20]; |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
60 size_t size; |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
61 char **strings; |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
62 size_t i; |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
63 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
64 size = backtrace(stack, 20); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
65 strings = backtrace_symbols(stack, size); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
66 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
67 g_printerr("Stacktrace (%zd frames):\n", size); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
68 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
69 for (i = 0; i < size; i++) |
2785 | 70 g_printerr(" %ld. %s\n", (long)i + 1, strings[i]); |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
71 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
72 g_free(strings); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
73 } |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
74 #else |
4431
6456eadfe0ca
Updated bugtracker URL and made the sig11 handler tiny bit more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
4412
diff
changeset
|
75 g_printerr(_("Stacktrace was unavailable. You might want to reproduce this " |
6456eadfe0ca
Updated bugtracker URL and made the sig11 handler tiny bit more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
4412
diff
changeset
|
76 "problem while running Audacious under GDB to get a proper backtrace.\n")); |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
77 #endif |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
78 |
4431
6456eadfe0ca
Updated bugtracker URL and made the sig11 handler tiny bit more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
4412
diff
changeset
|
79 g_printerr(_("\nBugs can be reported at http://bugzilla.atheme.org/ against " |
6456eadfe0ca
Updated bugtracker URL and made the sig11 handler tiny bit more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
4412
diff
changeset
|
80 "the Audacious or Audacious Plugins product.\n")); |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
81 |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
82 g_critical("Received SIGSEGV -- Audacious has crashed."); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
83 |
4412
180996fcf12a
bmp_config_* -> aud_config_*
Matti Hamalainen <ccr@tnsp.org>
parents:
4345
diff
changeset
|
84 aud_config_save(); |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
85 abort(); |
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
86 } |
2313 | 87 |
4693
463675303b6f
Fix preprocessor logic.
William Pitcock <nenolod@atheme.org>
parents:
4692
diff
changeset
|
88 #if (!defined(HAVE_SIGNALFD) || !defined(HAVE_SYS_SIGNALFD_H)) |
4690
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
89 |
2629 | 90 static void * |
91 signal_process_signals (void *data) | |
2313 | 92 { |
2629 | 93 sigset_t waitset; |
94 int sig; | |
95 | |
96 sigemptyset(&waitset); | |
97 sigaddset(&waitset, SIGPIPE); | |
98 sigaddset(&waitset, SIGSEGV); | |
99 sigaddset(&waitset, SIGINT); | |
100 sigaddset(&waitset, SIGTERM); | |
2313 | 101 |
2629 | 102 while(1) { |
103 sigwait(&waitset, &sig); | |
2313 | 104 |
2629 | 105 switch(sig){ |
106 case SIGPIPE: | |
107 /* | |
108 * do something. | |
109 */ | |
110 break; | |
2313 | 111 |
2629 | 112 case SIGSEGV: |
2661
f6c7271df7de
[svn] - use execinfo.h to provide more useful information about crashes
nenolod
parents:
2638
diff
changeset
|
113 signal_process_segv(); |
2629 | 114 break; |
2313 | 115 |
2629 | 116 case SIGINT: |
117 g_print("Audacious has received SIGINT and is shutting down.\n"); | |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4431
diff
changeset
|
118 aud_quit(); |
2629 | 119 break; |
120 | |
121 case SIGTERM: | |
122 g_print("Audacious has received SIGTERM and is shutting down.\n"); | |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4431
diff
changeset
|
123 aud_quit(); |
2629 | 124 break; |
125 } | |
2313 | 126 } |
127 | |
2629 | 128 return NULL; //dummy |
2313 | 129 } |
130 | |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
131 /********************************************************************************/ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
132 /* for linuxthread */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
133 /********************************************************************************/ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
134 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
135 typedef void (*SignalHandler) (gint); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
136 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
137 static void * |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
138 signal_process_signals_linuxthread (void *data) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
139 { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
140 while(1) { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
141 g_usleep(1000000); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
142 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
143 switch(linuxthread_signal_number){ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
144 case SIGPIPE: |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
145 /* |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
146 * do something. |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
147 */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
148 linuxthread_signal_number = 0; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
149 break; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
150 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
151 case SIGSEGV: |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
152 signal_process_segv(); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
153 break; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
154 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
155 case SIGINT: |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
156 g_print("Audacious has received SIGINT and is shutting down.\n"); |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4431
diff
changeset
|
157 aud_quit(); |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
158 break; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
159 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
160 case SIGTERM: |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
161 g_print("Audacious has received SIGTERM and is shutting down.\n"); |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4431
diff
changeset
|
162 aud_quit(); |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
163 break; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
164 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
165 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
166 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
167 return NULL; //dummy |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
168 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
169 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
170 static void |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
171 linuxthread_handler (gint signal_number) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
172 { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
173 /* note: cannot manipulate mutex from signal handler */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
174 linuxthread_signal_number = signal_number; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
175 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
176 |
4690
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
177 #else |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
178 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
179 #include <sys/signalfd.h> |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
180 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
181 static gpointer |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
182 signal_process_signals(gpointer data) |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
183 { |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
184 struct signalfd_siginfo d; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
185 sigset_t waitset; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
186 int sigfd; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
187 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
188 sigemptyset(&waitset); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
189 sigaddset(&waitset, SIGPIPE); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
190 sigaddset(&waitset, SIGSEGV); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
191 sigaddset(&waitset, SIGINT); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
192 sigaddset(&waitset, SIGTERM); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
193 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
194 sigfd = signalfd(-1, &waitset, 0); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
195 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
196 while (read(sigfd, &d, sizeof(struct signalfd_siginfo)) > 0) |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
197 { |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
198 switch(d.ssi_signo) |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
199 { |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
200 case SIGPIPE: |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
201 /* |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
202 * do something. |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
203 */ |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
204 break; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
205 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
206 case SIGSEGV: |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
207 signal_process_segv(); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
208 break; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
209 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
210 case SIGINT: |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
211 g_print("Audacious has received SIGINT and is shutting down.\n"); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
212 aud_quit(); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
213 break; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
214 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
215 case SIGTERM: |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
216 g_print("Audacious has received SIGTERM and is shutting down.\n"); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
217 aud_quit(); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
218 break; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
219 } |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
220 } |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
221 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
222 close(sigfd); |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
223 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
224 return NULL; |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
225 } |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
226 |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
227 #endif |
cd1e4d4aa0b9
Take advantage of signalfd if available.
William Pitcock <nenolod@atheme.org>
parents:
4492
diff
changeset
|
228 |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
229 static SignalHandler |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
230 signal_install_handler_full (gint signal_number, |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
231 SignalHandler handler, |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
232 gint *signals_to_block, |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
233 gsize n_signals) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
234 { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
235 struct sigaction action, old_action; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
236 gsize i; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
237 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
238 action.sa_handler = handler; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
239 action.sa_flags = SA_RESTART; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
240 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
241 sigemptyset (&action.sa_mask); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
242 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
243 for (i = 0; i < n_signals; i++) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
244 sigaddset (&action.sa_mask, signals_to_block[i]); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
245 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
246 if (sigaction (signal_number, &action, &old_action) == -1) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
247 { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
248 g_message ("Failed to install handler for signal %d", signal_number); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
249 return NULL; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
250 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
251 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
252 return old_action.sa_handler; |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
253 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
254 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
255 /* |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
256 * A version of signal() that works more reliably across different |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
257 * platforms. It: |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
258 * a. restarts interrupted system calls |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
259 * b. does not reset the handler |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
260 * c. blocks the same signal within the handler |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
261 * |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
262 * (adapted from Unix Network Programming Vol. 1) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
263 */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
264 static SignalHandler |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
265 signal_install_handler (gint signal_number, |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
266 SignalHandler handler) |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
267 { |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
268 return signal_install_handler_full (signal_number, handler, NULL, 0); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
269 } |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
270 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
271 |
2664
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
272 /* sets up blocking signals for pthreads. |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
273 * linuxthreads sucks and needs this to make sigwait(2) work |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
274 * correctly. --nenolod |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
275 * |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
276 * correction -- this trick does not work on linuxthreads. |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
277 * going to keep it in it's own function though --nenolod |
2664
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
278 */ |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
279 static void |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
280 signal_initialize_blockers(void) |
2313 | 281 { |
2629 | 282 sigset_t blockset; |
2486 | 283 |
2629 | 284 sigemptyset(&blockset); |
285 sigaddset(&blockset, SIGPIPE); | |
286 sigaddset(&blockset, SIGSEGV); | |
287 sigaddset(&blockset, SIGINT); | |
288 sigaddset(&blockset, SIGTERM); | |
2313 | 289 |
2674
f3ee0b78150a
[svn] - use pthread_sigmask(SIG_BLOCK, ...) instead of of SIG_SETMASK
nenolod
parents:
2666
diff
changeset
|
290 if(pthread_sigmask(SIG_BLOCK, &blockset, NULL)) |
2664
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
291 g_print("pthread_sigmask() failed.\n"); |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
292 } |
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
293 |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
294 static gboolean |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
295 signal_check_for_broken_impl(void) |
2664
1d9c5db3341d
[svn] - handle sigwait(2) brokenness on linuxthreads
nenolod
parents:
2661
diff
changeset
|
296 { |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
297 #ifdef _CS_GNU_LIBPTHREAD_VERSION |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
298 { |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
299 gchar str[1024]; |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
300 confstr(_CS_GNU_LIBPTHREAD_VERSION, str, sizeof(str)); |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
301 |
4069
b26a96a5da69
change code a bit to avoid using strncasecmp which gives a warning here
mf0102 <0102@gmx.at>
parents:
3123
diff
changeset
|
302 if (g_ascii_strncasecmp("linuxthreads", str, 12) == 0) |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
303 return TRUE; |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
304 } |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
305 #endif |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
306 |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
307 return FALSE; |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
308 } |
2313 | 309 |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
310 #ifdef USE_EGGSM |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
311 static void |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
312 signal_session_quit_cb(EggSMClient *client, gpointer user_data) |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
313 { |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
314 g_print("Session quit requested. Saving state and shutting down.\n"); |
4449
19e3f3c5fe7f
introduce function aud_quit(), which is basically mainwin_quit_cb(), but
mf0102 <0102@gmx.at>
parents:
4431
diff
changeset
|
315 aud_quit(); |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
316 } |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
317 |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
318 static void |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
319 signal_session_save_cb(EggSMClient *client, const char *state_dir, gpointer user_data) |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
320 { |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
321 g_print("Session save requested. Saving state.\n"); |
4412
180996fcf12a
bmp_config_* -> aud_config_*
Matti Hamalainen <ccr@tnsp.org>
parents:
4345
diff
changeset
|
322 aud_config_save(); |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
323 } |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
324 #endif |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
325 |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
326 void |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
327 signal_handlers_init(void) |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
328 { |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
329 #ifdef USE_EGGSM |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
330 EggSMClient *client; |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
331 |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
332 client = egg_sm_client_get (); |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
333 if (client != NULL) |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
334 { |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
335 egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_NORMAL); |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
336 g_signal_connect (client, "quit", |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
337 G_CALLBACK (signal_session_quit_cb), NULL); |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
338 g_signal_connect (client, "save-state", |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
339 G_CALLBACK (signal_session_save_cb), NULL); |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
340 |
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
341 } |
4492
55262ebeba2d
Conditional support for SM (libeggsmclient).
Matti Hamalainen <ccr@tnsp.org>
parents:
4449
diff
changeset
|
342 #endif |
4315
c942eaef7bc6
Implement session management.
Ivan N. Zlatev <contact@i-nz.net>
parents:
4069
diff
changeset
|
343 |
4693
463675303b6f
Fix preprocessor logic.
William Pitcock <nenolod@atheme.org>
parents:
4692
diff
changeset
|
344 #if (!defined(HAVE_SIGNALFD) || !defined(HAVE_SYS_SIGNALFD_H)) |
4692
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
345 |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
346 if (signal_check_for_broken_impl() != TRUE) |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
347 { |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
348 signal_initialize_blockers(); |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
349 g_thread_create(signal_process_signals, NULL, FALSE, NULL); |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
350 } |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
351 else |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
352 { |
2666
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
353 g_printerr(_("Your signaling implementation is broken.\n" |
78a8b3095274
[svn] - do not use the signal handler at all on linuxthreads and hope for the best
nenolod
parents:
2665
diff
changeset
|
354 "Expect unusable crash reports.\n")); |
2677
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
355 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
356 /* install special handler which catches signals and forwards to the signal handling thread */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
357 signal_install_handler(SIGPIPE, linuxthread_handler); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
358 signal_install_handler(SIGSEGV, linuxthread_handler); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
359 signal_install_handler(SIGINT, linuxthread_handler); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
360 signal_install_handler(SIGTERM, linuxthread_handler); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
361 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
362 /* create handler thread */ |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
363 g_thread_create(signal_process_signals_linuxthread, NULL, FALSE, NULL); |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
364 |
52785bdac597
[svn] - workaround for linuxthread's broken implementation of sigwait().
yaz
parents:
2674
diff
changeset
|
365 } |
4692
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
366 |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
367 #else |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
368 |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
369 signal_initialize_blockers(); |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
370 g_thread_create(signal_process_signals, NULL, FALSE, NULL); |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
371 |
84f70d4b36e6
Fix compile when signalfd is not available entirely.
William Pitcock <nenolod@atheme.org>
parents:
4690
diff
changeset
|
372 #endif |
2313 | 373 } |