summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-01-06 17:37:12 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2018-01-06 18:20:23 +0900
commit2fb80270ba978d3d30915007b275cdbd57b3e433 (patch)
treee53bd4f2b25dacd9304ece64706e0ad32d812df7
parent0d845ce3aa88738e5313d81745f882e011333204 (diff)
efl thread signal masks - fix up for various threads manually created
so xine module plus 2 eina dbug threads didnt set up signal blocking/masks correctly. xine use ssigprocmask not pthread_sigmask and the other 2 didnt even bother at all. fix this so these threads all block most of these commnly caught signals so these threads never get them
-rw-r--r--src/lib/eina/eina_debug_cpu.c22
-rw-r--r--src/lib/eina/eina_debug_timer.c21
-rw-r--r--src/modules/emotion/xine/emotion_xine.c4
3 files changed, 45 insertions, 2 deletions
diff --git a/src/lib/eina/eina_debug_cpu.c b/src/lib/eina/eina_debug_cpu.c
index 0f25b4bfbd..20f83b7cea 100644
--- a/src/lib/eina/eina_debug_cpu.c
+++ b/src/lib/eina/eina_debug_cpu.c
@@ -8,6 +8,7 @@
8#include <errno.h> 8#include <errno.h>
9#include <unistd.h> 9#include <unistd.h>
10#include <pthread.h> 10#include <pthread.h>
11#include <signal.h>
11#include <sys/types.h> 12#include <sys/types.h>
12#include <sys/stat.h> 13#include <sys/stat.h>
13#include <fcntl.h> 14#include <fcntl.h>
@@ -294,12 +295,32 @@ Eina_Bool
294_eina_debug_cpu_init(void) 295_eina_debug_cpu_init(void)
295{ 296{
296 // if it's already running - we're good. 297 // if it's already running - we're good.
298#ifndef _WIN32
297 if (!_sysmon_thread_runs) 299 if (!_sysmon_thread_runs)
298 { 300 {
299 int err; 301 int err;
302 sigset_t oldset, newset;
303
300 eina_lock_new(&_sysmon_lock); 304 eina_lock_new(&_sysmon_lock);
301 eina_lock_take(&_sysmon_lock); 305 eina_lock_take(&_sysmon_lock);
306 sigemptyset(&newset);
307 sigaddset(&newset, SIGPIPE);
308 sigaddset(&newset, SIGALRM);
309 sigaddset(&newset, SIGCHLD);
310 sigaddset(&newset, SIGUSR1);
311 sigaddset(&newset, SIGUSR2);
312 sigaddset(&newset, SIGHUP);
313 sigaddset(&newset, SIGQUIT);
314 sigaddset(&newset, SIGINT);
315 sigaddset(&newset, SIGTERM);
316#ifdef SIGPWR
317 sigaddset(&newset, SIGPWR);
318#endif
319 pthread_sigmask(SIG_BLOCK, &newset, &oldset);
320
302 err = pthread_create(&_sysmon_thread, NULL, _sysmon, NULL); 321 err = pthread_create(&_sysmon_thread, NULL, _sysmon, NULL);
322
323 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
303 if (err != 0) 324 if (err != 0)
304 { 325 {
305 e_debug("EINA DEBUG ERROR: Can't create debug sysmon thread!"); 326 e_debug("EINA DEBUG ERROR: Can't create debug sysmon thread!");
@@ -308,6 +329,7 @@ _eina_debug_cpu_init(void)
308 _sysmon_thread_runs = EINA_TRUE; 329 _sysmon_thread_runs = EINA_TRUE;
309 } 330 }
310 eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL); 331 eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
332#endif
311 return EINA_TRUE; 333 return EINA_TRUE;
312} 334}
313 335
diff --git a/src/lib/eina/eina_debug_timer.c b/src/lib/eina/eina_debug_timer.c
index 26b93e5fd4..610869c2dc 100644
--- a/src/lib/eina/eina_debug_timer.c
+++ b/src/lib/eina/eina_debug_timer.c
@@ -160,7 +160,28 @@ eina_debug_timer_add(unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data
160 _timer_append(t); 160 _timer_append(t);
161 if (!_thread_runs) 161 if (!_thread_runs)
162 { 162 {
163#ifndef _WIN32
164 sigset_t oldset, newset;
165
166 sigemptyset(&newset);
167 sigaddset(&newset, SIGPIPE);
168 sigaddset(&newset, SIGALRM);
169 sigaddset(&newset, SIGCHLD);
170 sigaddset(&newset, SIGUSR1);
171 sigaddset(&newset, SIGUSR2);
172 sigaddset(&newset, SIGHUP);
173 sigaddset(&newset, SIGQUIT);
174 sigaddset(&newset, SIGINT);
175 sigaddset(&newset, SIGTERM);
176# ifdef SIGPWR
177 sigaddset(&newset, SIGPWR);
178# endif
179 pthread_sigmask(SIG_BLOCK, &newset, &oldset);
180#endif
163 int err = pthread_create(&_thread, NULL, _monitor, NULL); 181 int err = pthread_create(&_thread, NULL, _monitor, NULL);
182#ifndef _WIN32
183 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
184#endif
164 if (err != 0) 185 if (err != 0)
165 { 186 {
166 e_debug("EINA DEBUG ERROR: Can't create debug timer thread!"); 187 e_debug("EINA DEBUG ERROR: Can't create debug timer thread!");
diff --git a/src/modules/emotion/xine/emotion_xine.c b/src/modules/emotion/xine/emotion_xine.c
index dc89ee0eb1..4beaa64e9a 100644
--- a/src/modules/emotion/xine/emotion_xine.c
+++ b/src/modules/emotion/xine/emotion_xine.c
@@ -382,10 +382,10 @@ em_add(const Emotion_Engine *api EINA_UNUSED,
382#ifdef SIGPWR 382#ifdef SIGPWR
383 sigaddset(&newset, SIGPWR); 383 sigaddset(&newset, SIGPWR);
384#endif 384#endif
385 sigprocmask(SIG_BLOCK, &newset, &oldset); 385 pthread_sigmask(SIG_BLOCK, &newset, &oldset);
386 pthread_create(&ev->get_pos_len_th, NULL, _em_get_pos_len_th, ev); 386 pthread_create(&ev->get_pos_len_th, NULL, _em_get_pos_len_th, ev);
387 pthread_create(&ev->slave_th, NULL, _em_slave, ev); 387 pthread_create(&ev->slave_th, NULL, _em_slave, ev);
388 sigprocmask(SIG_SETMASK, &oldset, NULL); 388 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
389 389
390 pthread_detach(ev->slave_th); 390 pthread_detach(ev->slave_th);
391 _em_slave_event(ev, 1, NULL); 391 _em_slave_event(ev, 1, NULL);