From ab27c8594898b2d73f9508c55548426987780a4e Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 19 Aug 2015 14:54:19 +0200 Subject: [PATCH] Implement sigaction(2) SA_RESETHAND. --- kernel/signal.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/signal.cpp b/kernel/signal.cpp index 81954cb4..3621e142 100644 --- a/kernel/signal.cpp +++ b/kernel/signal.cpp @@ -767,11 +767,16 @@ retry_another_signal: // Update the current registers. Scheduler::LoadInterruptedContext(intctx, &handler_regs); - // TODO: SA_RESETHAND: - // "If set, the disposition of the signal shall be reset to SIG_DFL - // and the SA_SIGINFO flag shall be cleared on entry to the signal - // handler. Note: SIGILL and SIGTRAP cannot be automatically reset - // when delivered; the system silently enforces this restriction." + // Reset the signal handler if this signal handler is once only. + if ( action->sa_flags & SA_RESETHAND ) + { + // POSIX mandates SA_RESETHAND is silently ignored for these signals. + if ( signum != SIGILL && signum != SIGTRAP ) + { + action->sa_flags &= ~SA_RESETHAND; + action->sa_handler = SIG_DFL; + } + } // Run the signal handler by returning to user-space. return;