From 8f05d0363949a808b0f150432010503985ad538f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 23 Jul 2018 17:30:56 -0400 Subject: [PATCH] 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 --- src/lib/ecore/ecore_signal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/ecore/ecore_signal.c b/src/lib/ecore/ecore_signal.c index e03233dcae..f970842d31 100644 --- a/src/lib/ecore/ecore_signal.c +++ b/src/lib/ecore/ecore_signal.c @@ -39,6 +39,7 @@ static Eo *sig_pipe_handler = NULL; static Eina_Spinlock sig_pid_lock; static Eina_List *sig_pid_info_list = NULL; +volatile int pipe_dead = 0; volatile int exit_signal_received = 0; typedef struct _Signal_Data @@ -53,6 +54,7 @@ _ecore_signal_pipe_read(Eo *obj) Signal_Data sdata; int ret; + if (pipe_dead) return EINA_TRUE; ret = read(sig_pipe[0], &sdata, sizeof(sdata)); if (ret != sizeof(sdata)) return EINA_FALSE; switch (sdata.sig) @@ -165,6 +167,7 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED) if (sdata.sig >= 0) { int err = errno; + if (pipe_dead) return; const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata)); if (EINA_UNLIKELY(bytes != sizeof(sdata))) { @@ -283,6 +286,7 @@ _ecore_signal_cb_fork(void *data EINA_UNUSED) void _ecore_signal_init(void) { + pipe_dead = 0; _ecore_signal_pipe_init(); ecore_fork_reset_callback_add(_ecore_signal_cb_fork, NULL); } @@ -293,6 +297,7 @@ _ecore_signal_shutdown(void) sigset_t newset; ecore_fork_reset_callback_del(_ecore_signal_cb_fork, NULL); + pipe_dead = 1; // we probably should restore.. but not a good idea // pthread_sigmask(SIG_SETMASK, &sig_oldset, NULL); // at least do not trigger signal callback after shutdown