aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Vivier <laurent@vivier.eu>2020-02-12 13:56:56 +0100
committerLaurent Vivier <laurent@vivier.eu>2020-02-12 18:56:32 +0100
commit365510fb860a91dbead7d6c9e5815ef9d4e72062 (patch)
treeb186da4d9c843ad280e42d882809a23663b9a7be
parent9d660adc3248b81618e7afc1ddef6c9731e1047f (diff)
downloadqemu-365510fb860a91dbead7d6c9e5815ef9d4e72062.zip
qemu-365510fb860a91dbead7d6c9e5815ef9d4e72062.tar.gz
qemu-365510fb860a91dbead7d6c9e5815ef9d4e72062.tar.bz2
linux-user: cleanup signal.c
No functional changes. Prepare the field for future fixes. Remove memset(.., 0, ...) that is useless on a static array Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <20200212125658.644558-3-laurent@vivier.eu>
-rw-r--r--linux-user/signal.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 5ca6d62..2463155 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -66,12 +66,6 @@ static uint8_t host_to_target_signal_table[_NSIG] = {
[SIGPWR] = TARGET_SIGPWR,
[SIGSYS] = TARGET_SIGSYS,
/* next signals stay the same */
- /* Nasty hack: Reverse SIGRTMIN and SIGRTMAX to avoid overlap with
- host libpthread signals. This assumes no one actually uses SIGRTMAX :-/
- To fix this properly we need to do manual signal delivery multiplexed
- over a single host signal. */
- [__SIGRTMIN] = __SIGRTMAX,
- [__SIGRTMAX] = __SIGRTMIN,
};
static uint8_t target_to_host_signal_table[_NSIG];
@@ -480,31 +474,45 @@ static int core_dump_signal(int sig)
}
}
+static void signal_table_init(void)
+{
+ int host_sig, target_sig;
+
+ /*
+ * Nasty hack: Reverse SIGRTMIN and SIGRTMAX to avoid overlap with
+ * host libpthread signals. This assumes no one actually uses SIGRTMAX :-/
+ * To fix this properly we need to do manual signal delivery multiplexed
+ * over a single host signal.
+ */
+ host_to_target_signal_table[__SIGRTMIN] = __SIGRTMAX;
+ host_to_target_signal_table[__SIGRTMAX] = __SIGRTMIN;
+
+ /* generate signal conversion tables */
+ for (host_sig = 1; host_sig < _NSIG; host_sig++) {
+ if (host_to_target_signal_table[host_sig] == 0) {
+ host_to_target_signal_table[host_sig] = host_sig;
+ }
+ }
+ for (host_sig = 1; host_sig < _NSIG; host_sig++) {
+ target_sig = host_to_target_signal_table[host_sig];
+ target_to_host_signal_table[target_sig] = host_sig;
+ }
+}
+
void signal_init(void)
{
TaskState *ts = (TaskState *)thread_cpu->opaque;
struct sigaction act;
struct sigaction oact;
- int i, j;
+ int i;
int host_sig;
- /* generate signal conversion tables */
- for(i = 1; i < _NSIG; i++) {
- if (host_to_target_signal_table[i] == 0)
- host_to_target_signal_table[i] = i;
- }
- for(i = 1; i < _NSIG; i++) {
- j = host_to_target_signal_table[i];
- target_to_host_signal_table[j] = i;
- }
+ /* initialize signal conversion tables */
+ signal_table_init();
/* Set the signal mask from the host mask. */
sigprocmask(0, 0, &ts->signal_mask);
- /* set all host signal handlers. ALL signals are blocked during
- the handlers to serialize them. */
- memset(sigact_table, 0, sizeof(sigact_table));
-
sigfillset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
act.sa_sigaction = host_signal_handler;