From a50a4384613a18d21c5ecb5fec2482775607fc91 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Tue, 26 Sep 2023 19:59:48 +0800 Subject: [PATCH] Ignore handling SIG_DFL/SIG_IGN for previous sig action (#2589) --- core/shared/platform/common/posix/posix_thread.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/core/shared/platform/common/posix/posix_thread.c b/core/shared/platform/common/posix/posix_thread.c index a0b18440..a7bdc6d1 100644 --- a/core/shared/platform/common/posix/posix_thread.c +++ b/core/shared/platform/common/posix/posix_thread.c @@ -543,14 +543,12 @@ signal_callback(int sig_num, siginfo_t *sig_info, void *sig_ucontext) if (prev_sig_act && (prev_sig_act->sa_flags & SA_SIGINFO)) { prev_sig_act->sa_sigaction(sig_num, sig_info, sig_ucontext); } - else if (prev_sig_act && (void *)prev_sig_act->sa_handler == SIG_DFL) { - /* Default action */ - sigaction(sig_num, prev_sig_act, NULL); - } - else if (prev_sig_act && (void *)prev_sig_act->sa_handler == SIG_IGN) { - /* Ignore this signal */ - } - else if (prev_sig_act && prev_sig_act->sa_handler) { + else if (prev_sig_act + && prev_sig_act->sa_handler + /* Filter out SIG_DFL and SIG_IGN here, they will + run into the else branch below */ + && (void *)prev_sig_act->sa_handler != SIG_DFL + && (void *)prev_sig_act->sa_handler != SIG_IGN) { prev_sig_act->sa_handler(sig_num); } /* Output signal info and then crash if signal is unhandled */