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
parent efaff210
......@@ -8,6 +8,7 @@
#include <errno.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
......@@ -294,12 +295,32 @@ Eina_Bool
_eina_debug_cpu_init(void)
{
// if it's already running - we're good.
#ifndef _WIN32
if (!_sysmon_thread_runs)
{
int err;
sigset_t oldset, newset;
eina_lock_new(&_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);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (err != 0)
{
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;
}
eina_debug_opcodes_register(NULL, _OPS(), NULL, NULL);
#endif
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);
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);
#ifndef _WIN32
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
#endif
if (err != 0)
{
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
sigaddset(&newset, SIGPWR);
#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->slave_th, NULL, _em_slave, ev);
sigprocmask(SIG_SETMASK, &oldset, NULL);
pthread_sigmask(SIG_SETMASK, &oldset, NULL);
pthread_detach(ev->slave_th);
_em_slave_event(ev, 1, NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment