forked from enlightenment/efl
ecore/signal: use a volatile int to prevent further SIGPIPE during shutdown
Summary: attempt to prevent any access of the signal pipe once signal handlers are removed in order to avoid triggering a SIGPIPE which would kill the app Depends on D6670 Reviewers: ManMower Reviewed By: ManMower Subscribers: cedric, #committers Tags: #efl_main_loop Differential Revision: https://phab.enlightenment.org/D6672
This commit is contained in:
parent
bf92738a57
commit
8f05d03639
|
@ -39,6 +39,7 @@ static Eo *sig_pipe_handler = NULL;
|
||||||
static Eina_Spinlock sig_pid_lock;
|
static Eina_Spinlock sig_pid_lock;
|
||||||
static Eina_List *sig_pid_info_list = NULL;
|
static Eina_List *sig_pid_info_list = NULL;
|
||||||
|
|
||||||
|
volatile int pipe_dead = 0;
|
||||||
volatile int exit_signal_received = 0;
|
volatile int exit_signal_received = 0;
|
||||||
|
|
||||||
typedef struct _Signal_Data
|
typedef struct _Signal_Data
|
||||||
|
@ -53,6 +54,7 @@ _ecore_signal_pipe_read(Eo *obj)
|
||||||
Signal_Data sdata;
|
Signal_Data sdata;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (pipe_dead) return EINA_TRUE;
|
||||||
ret = read(sig_pipe[0], &sdata, sizeof(sdata));
|
ret = read(sig_pipe[0], &sdata, sizeof(sdata));
|
||||||
if (ret != sizeof(sdata)) return EINA_FALSE;
|
if (ret != sizeof(sdata)) return EINA_FALSE;
|
||||||
switch (sdata.sig)
|
switch (sdata.sig)
|
||||||
|
@ -165,6 +167,7 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED)
|
||||||
if (sdata.sig >= 0)
|
if (sdata.sig >= 0)
|
||||||
{
|
{
|
||||||
int err = errno;
|
int err = errno;
|
||||||
|
if (pipe_dead) return;
|
||||||
const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
|
const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
|
||||||
if (EINA_UNLIKELY(bytes != sizeof(sdata)))
|
if (EINA_UNLIKELY(bytes != sizeof(sdata)))
|
||||||
{
|
{
|
||||||
|
@ -283,6 +286,7 @@ _ecore_signal_cb_fork(void *data EINA_UNUSED)
|
||||||
void
|
void
|
||||||
_ecore_signal_init(void)
|
_ecore_signal_init(void)
|
||||||
{
|
{
|
||||||
|
pipe_dead = 0;
|
||||||
_ecore_signal_pipe_init();
|
_ecore_signal_pipe_init();
|
||||||
ecore_fork_reset_callback_add(_ecore_signal_cb_fork, NULL);
|
ecore_fork_reset_callback_add(_ecore_signal_cb_fork, NULL);
|
||||||
}
|
}
|
||||||
|
@ -293,6 +297,7 @@ _ecore_signal_shutdown(void)
|
||||||
sigset_t newset;
|
sigset_t newset;
|
||||||
|
|
||||||
ecore_fork_reset_callback_del(_ecore_signal_cb_fork, NULL);
|
ecore_fork_reset_callback_del(_ecore_signal_cb_fork, NULL);
|
||||||
|
pipe_dead = 1;
|
||||||
// we probably should restore.. but not a good idea
|
// we probably should restore.. but not a good idea
|
||||||
// pthread_sigmask(SIG_SETMASK, &sig_oldset, NULL);
|
// pthread_sigmask(SIG_SETMASK, &sig_oldset, NULL);
|
||||||
// at least do not trigger signal callback after shutdown
|
// at least do not trigger signal callback after shutdown
|
||||||
|
|
Loading…
Reference in New Issue