summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-23 17:30:56 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-07-23 17:30:56 -0400
commit8f05d0363949a808b0f150432010503985ad538f (patch)
tree376137e6f1b42748610bc1462e9e27bc83ac0d6f
parentbf92738a5778b9525e3db04d581fa468379183f2 (diff)
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
-rw-r--r--src/lib/ecore/ecore_signal.c5
1 files changed, 5 insertions, 0 deletions
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;
39static Eina_Spinlock sig_pid_lock; 39static Eina_Spinlock sig_pid_lock;
40static Eina_List *sig_pid_info_list = NULL; 40static Eina_List *sig_pid_info_list = NULL;
41 41
42volatile int pipe_dead = 0;
42volatile int exit_signal_received = 0; 43volatile int exit_signal_received = 0;
43 44
44typedef struct _Signal_Data 45typedef struct _Signal_Data
@@ -53,6 +54,7 @@ _ecore_signal_pipe_read(Eo *obj)
53 Signal_Data sdata; 54 Signal_Data sdata;
54 int ret; 55 int ret;
55 56
57 if (pipe_dead) return EINA_TRUE;
56 ret = read(sig_pipe[0], &sdata, sizeof(sdata)); 58 ret = read(sig_pipe[0], &sdata, sizeof(sdata));
57 if (ret != sizeof(sdata)) return EINA_FALSE; 59 if (ret != sizeof(sdata)) return EINA_FALSE;
58 switch (sdata.sig) 60 switch (sdata.sig)
@@ -165,6 +167,7 @@ _ecore_signal_callback(int sig, siginfo_t *si, void *foo EINA_UNUSED)
165 if (sdata.sig >= 0) 167 if (sdata.sig >= 0)
166 { 168 {
167 int err = errno; 169 int err = errno;
170 if (pipe_dead) return;
168 const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata)); 171 const ssize_t bytes = write(sig_pipe[1], &sdata, sizeof(sdata));
169 if (EINA_UNLIKELY(bytes != sizeof(sdata))) 172 if (EINA_UNLIKELY(bytes != sizeof(sdata)))
170 { 173 {
@@ -283,6 +286,7 @@ _ecore_signal_cb_fork(void *data EINA_UNUSED)
283void 286void
284_ecore_signal_init(void) 287_ecore_signal_init(void)
285{ 288{
289 pipe_dead = 0;
286 _ecore_signal_pipe_init(); 290 _ecore_signal_pipe_init();
287 ecore_fork_reset_callback_add(_ecore_signal_cb_fork, NULL); 291 ecore_fork_reset_callback_add(_ecore_signal_cb_fork, NULL);
288} 292}
@@ -293,6 +297,7 @@ _ecore_signal_shutdown(void)
293 sigset_t newset; 297 sigset_t newset;
294 298
295 ecore_fork_reset_callback_del(_ecore_signal_cb_fork, NULL); 299 ecore_fork_reset_callback_del(_ecore_signal_cb_fork, NULL);
300 pipe_dead = 1;
296 // we probably should restore.. but not a good idea 301 // we probably should restore.. but not a good idea
297 // pthread_sigmask(SIG_SETMASK, &sig_oldset, NULL); 302 // pthread_sigmask(SIG_SETMASK, &sig_oldset, NULL);
298 // at least do not trigger signal callback after shutdown 303 // at least do not trigger signal callback after shutdown