From de9e20ce892f8bd3d2868dea34146a89e7e5a838 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Tue, 14 Jul 2020 13:56:59 -0400 Subject: [PATCH] chore: Improve default signal handler --- runtime/src/software_interrupt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/src/software_interrupt.c b/runtime/src/software_interrupt.c index b6244c8..2370d4e 100644 --- a/runtime/src/software_interrupt.c +++ b/runtime/src/software_interrupt.c @@ -102,9 +102,6 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void case SIGUSR1: { /* SIGUSR1 restores a preempted sandbox using mcontext. */ - /* Assumption: Always sent by a thread, never by the kernel */ - assert(signal_info->si_code == SI_TKILL); - /* Assumption: Caller disables interrupt before triggering SIGUSR1 */ assert(!software_interrupt_is_enabled()); @@ -121,7 +118,12 @@ software_interrupt_handle_signals(int signal_type, siginfo_t *signal_info, void return; } default: - panic("Handler unexpectedly called for signal other than SIGALRM or SIGUSR1\n"); + if (signal_info->si_code == SI_TKILL) { + panic("Unexpectedly received signal %d from a thread kill, but we have no handler\n", + signal_type); + } else if (signal_info->si_code == SI_KERNEL) { + panic("Unexpectedly received signal %d from the kernel, but we have no handler\n", signal_type); + } } #endif }