diff options
-rw-r--r-- | src/jobs.c | 1 | ||||
-rw-r--r-- | src/sig-monitor.c | 26 |
2 files changed, 25 insertions, 2 deletions
@@ -915,6 +915,7 @@ void jobs_exit(void (*handler)()) } /* wake up the threads */ + evloop_wakeup(); pthread_cond_broadcast(&cond); /* leave */ diff --git a/src/sig-monitor.c b/src/sig-monitor.c index 70592812..c64306db 100644 --- a/src/sig-monitor.c +++ b/src/sig-monitor.c @@ -284,9 +284,9 @@ static void on_rescue_exit(int signum) } /* - * Do a safe exit + * Do a direct safe exit */ -static void safe_exit(int code) +static void direct_safe_exit(int code) { set_signals_handler(on_rescue_exit, sigerr); set_signals_handler(on_rescue_exit, sigterm); @@ -294,6 +294,28 @@ static void safe_exit(int code) exit(code); } +/* + * Do a safe exit + */ +#if WITH_SIG_MONITOR_NO_DEFERRED_EXIT +# define safe_exit(x) direct_safe_exit(x) +#else +#include "jobs.h" +static void exit_job(int signum, void* arg) +{ + exiting = (int)(intptr_t)arg; + if (signum) + on_rescue_exit(signum); + exit(exiting); +} + +static void safe_exit(int code) +{ + if (jobs_queue(safe_exit, 0, exit_job, (void*)(intptr_t)code)) + direct_safe_exit(code); +} +#endif + #if !WITH_SIG_MONITOR_DUMPSTACK static inline void safe_dumpstack(int crop, int signum) {} |