From 1a93d0d79c907c7c48ee77a78cfee94f7708bb1d Mon Sep 17 00:00:00 2001 From: x_xiny <1301913191@qq.com> Date: Fri, 2 Apr 2021 17:40:55 +0800 Subject: [PATCH] signal Change-Id: Iacf0cc5918e3aad5def71aedbd048bd5d21ccca5 --- src/signal/sigaction.c | 13 +++++++++++++ src/signal/sigsuspend.c | 21 +++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c index 02b6a153..9cce43d7 100755 --- a/src/signal/sigaction.c +++ b/src/signal/sigaction.c @@ -183,7 +183,19 @@ static void __sig_operation(unsigned int receivedSigno) void arm_signal_process(unsigned int receivedSig) { + sigset_t mask, oldmask; + + sigemptyset(&mask); + sigemptyset(&oldmask); + + sigaddset(&mask, receivedSig); + sigprocmask(SIG_BLOCK, &mask, NULL); + __sig_operation(receivedSig); + + sigprocmask(SIG_BLOCK, NULL, &oldmask); + sigdelset(&oldmask, receivedSig); + sigprocmask(SIG_SETMASK, &oldmask, NULL); } static void __sig_add_def_action() @@ -255,6 +267,7 @@ static int __sig_action_opr(int sig, const sigaction_t *act, sigaction_t *oact) sigact->act.sa_mask = act->sa_mask; sigact->act.sa_flags = act->sa_flags; } + sigprocmask(SIG_BLOCK, &act->sa_mask, NULL); pthread_spin_unlock(&sig_lite_lock); return ret; } diff --git a/src/signal/sigsuspend.c b/src/signal/sigsuspend.c index 36e0602c..ab1f0bda 100644 --- a/src/signal/sigsuspend.c +++ b/src/signal/sigsuspend.c @@ -3,5 +3,22 @@ int sigsuspend(const sigset_t *mask) { - return syscall_cp(SYS_rt_sigsuspend, mask, _NSIG/8); -} + int ret,retval; + sigset_t oldset; + + retval = sigprocmask(SIG_BLOCK, 0, &oldset); + if (retval != 0){ + return retval; + } + + ret = syscall_cp(SYS_rt_sigsuspend, mask, _NSIG/8); + + if (ret == -1){ + retval = sigprocmask(SIG_SETMASK, &oldset, 0); + if (retval != 0){ + return retval; + } + } + + return ret; +} \ No newline at end of file -- GitLab