forked from enlightenment/efl
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
This commit is contained in:
parent
0d845ce3aa
commit
2fb80270ba
|
@ -8,6 +8,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -294,12 +295,32 @@ Eina_Bool
|
||||||
_eina_debug_cpu_init(void)
|
_eina_debug_cpu_init(void)
|
||||||
{
|
{
|
||||||
// if it's already running - we're good.
|
// if it's already running - we're good.
|
||||||
|
#ifndef _WIN32
|
||||||
if (!_sysmon_thread_runs)
|
if (!_sysmon_thread_runs)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
sigset_t oldset, newset;
|
||||||
|
|
||||||
eina_lock_new(&_sysmon_lock);
|
eina_lock_new(&_sysmon_lock);
|
||||||
eina_lock_take(&_sysmon_lock);
|
eina_lock_take(&_sysmon_lock);
|
||||||
|
sigemptyset(&newset);
|
||||||
|
sigaddset(&newset, SIGPIPE);
|
||||||
|
sigaddset(&newset, SIGALRM);
|
||||||
|
sigaddset(&newset, SIGCHLD);
|
||||||
|
sigaddset(&newset, SIGUSR1);
|
||||||
|
sigaddset(&newset, SIGUSR2);
|
||||||
|
sigaddset(&newset, SIGHUP);
|
||||||
|
sigaddset(&newset, SIGQUIT);
|
||||||
|
sigaddset(&newset, SIGINT);
|
||||||
|
sigaddset(&newset, SIGTERM);
|
||||||
|
#ifdef SIGPWR
|
||||||
|
sigaddset(&newset, SIGPWR);
|
||||||
|
#endif
|
||||||
|
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
|
||||||
|
|
||||||
err = pthread_create(&_sysmon_thread, NULL, _sysmon, NULL);
|
err = pthread_create(&_sysmon_thread, NULL, _sysmon, NULL);
|
||||||
|
|
||||||
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
e_debug("EINA DEBUG ERROR: Can't create debug sysmon thread!");
|
e_debug("EINA DEBUG ERROR: Can't create debug sysmon thread!");
|
||||||
|
@ -308,6 +329,7 @@ _eina_debug_cpu_init(void)
|
||||||
_sysmon_thread_runs = EINA_TRUE;
|
_sysmon_thread_runs = EINA_TRUE;
|
||||||
}
|
}
|
||||||
eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
|
eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
|
||||||
|
#endif
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,28 @@ eina_debug_timer_add(unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data
|
||||||
_timer_append(t);
|
_timer_append(t);
|
||||||
if (!_thread_runs)
|
if (!_thread_runs)
|
||||||
{
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
sigset_t oldset, newset;
|
||||||
|
|
||||||
|
sigemptyset(&newset);
|
||||||
|
sigaddset(&newset, SIGPIPE);
|
||||||
|
sigaddset(&newset, SIGALRM);
|
||||||
|
sigaddset(&newset, SIGCHLD);
|
||||||
|
sigaddset(&newset, SIGUSR1);
|
||||||
|
sigaddset(&newset, SIGUSR2);
|
||||||
|
sigaddset(&newset, SIGHUP);
|
||||||
|
sigaddset(&newset, SIGQUIT);
|
||||||
|
sigaddset(&newset, SIGINT);
|
||||||
|
sigaddset(&newset, SIGTERM);
|
||||||
|
# ifdef SIGPWR
|
||||||
|
sigaddset(&newset, SIGPWR);
|
||||||
|
# endif
|
||||||
|
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
|
||||||
|
#endif
|
||||||
int err = pthread_create(&_thread, NULL, _monitor, NULL);
|
int err = pthread_create(&_thread, NULL, _monitor, NULL);
|
||||||
|
#ifndef _WIN32
|
||||||
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
||||||
|
#endif
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
e_debug("EINA DEBUG ERROR: Can't create debug timer thread!");
|
e_debug("EINA DEBUG ERROR: Can't create debug timer thread!");
|
||||||
|
|
|
@ -382,10 +382,10 @@ em_add(const Emotion_Engine *api EINA_UNUSED,
|
||||||
#ifdef SIGPWR
|
#ifdef SIGPWR
|
||||||
sigaddset(&newset, SIGPWR);
|
sigaddset(&newset, SIGPWR);
|
||||||
#endif
|
#endif
|
||||||
sigprocmask(SIG_BLOCK, &newset, &oldset);
|
pthread_sigmask(SIG_BLOCK, &newset, &oldset);
|
||||||
pthread_create(&ev->get_pos_len_th, NULL, _em_get_pos_len_th, ev);
|
pthread_create(&ev->get_pos_len_th, NULL, _em_get_pos_len_th, ev);
|
||||||
pthread_create(&ev->slave_th, NULL, _em_slave, ev);
|
pthread_create(&ev->slave_th, NULL, _em_slave, ev);
|
||||||
sigprocmask(SIG_SETMASK, &oldset, NULL);
|
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
|
||||||
|
|
||||||
pthread_detach(ev->slave_th);
|
pthread_detach(ev->slave_th);
|
||||||
_em_slave_event(ev, 1, NULL);
|
_em_slave_event(ev, 1, NULL);
|
||||||
|
|
Loading…
Reference in New Issue