[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 27/30] bsd-user/signal.c: process_pending_signals
|
From: |
Warner Losh |
|
Subject: |
[PATCH 27/30] bsd-user/signal.c: process_pending_signals |
|
Date: |
Sun, 9 Jan 2022 09:19:20 -0700 |
Process the currently queued signals.
Signed-off-by: Stacey Son <sson@FreeBSD.org>
Signed-off-by: Kyle Evans <kevans@freebsd.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/signal.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index c954d0f4f37..1dd6dbb4ee1 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -781,6 +781,40 @@ static void handle_pending_signal(CPUArchState *cpu_env,
int sig,
void process_pending_signals(CPUArchState *cpu_env)
{
+ CPUState *cpu = env_cpu(cpu_env);
+ int sig;
+ sigset_t *blocked_set, set;
+ struct emulated_sigtable *k;
+ TaskState *ts = cpu->opaque;
+
+ while (qatomic_read(&ts->signal_pending)) {
+ /* FIXME: This is not threadsafe. */
+
+ sigfillset(&set);
+ sigprocmask(SIG_SETMASK, &set, 0);
+
+ k = ts->sigtab;
+ blocked_set = ts->in_sigsuspend ?
+ &ts->sigsuspend_mask : &ts->signal_mask;
+ for (sig = 1; sig <= TARGET_NSIG; sig++, k++) {
+ if (k->pending &&
+ !sigismember(blocked_set, target_to_host_signal(sig))) {
+ handle_pending_signal(cpu_env, sig, k);
+ }
+ }
+
+ /*
+ * unblock signals and check one more time. Unblocking signals may
cause
+ * us to take anothe rhost signal, which will set signal_pending again.
+ */
+ qatomic_set(&ts->signal_pending, 0);
+ ts->in_sigsuspend = false;
+ set = ts->signal_mask;
+ sigdelset(&set, SIGSEGV);
+ sigdelset(&set, SIGBUS);
+ sigprocmask(SIG_SETMASK, &set, 0);
+ }
+ ts->in_sigsuspend = false;
}
void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
--
2.33.1
- [PATCH 22/30] bsd-user/signal.c: Fill in queue_signal, (continued)
- [PATCH 26/30] bsd-user/signal.c: tswap_siginfo, Warner Losh, 2022/01/09
- [PATCH 28/30] bsd-user/signal.c: implement do_sigreturn, Warner Losh, 2022/01/09
- [PATCH 29/30] bsd-user/signal.c: implement do_sigaction, Warner Losh, 2022/01/09
- [PATCH 27/30] bsd-user/signal.c: process_pending_signals,
Warner Losh <=
- [PATCH 30/30] bsd-user/signal.c: do_sigaltstack, Warner Losh, 2022/01/09
- [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap, Warner Losh, 2022/01/09
- Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap, Richard Henderson, 2022/01/23