summaryrefslogtreecommitdiffstats
path: root/tests/ScopedSignalHandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ScopedSignalHandler.h')
-rw-r--r--tests/ScopedSignalHandler.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/ScopedSignalHandler.h b/tests/ScopedSignalHandler.h
index 3ec23b0..3fb60a1 100644
--- a/tests/ScopedSignalHandler.h
+++ b/tests/ScopedSignalHandler.h
@@ -18,17 +18,27 @@
#define _BIONIC_TESTS_SCOPED_SIGNAL_HANDLER_H
#include <signal.h>
+#include <string.h>
class ScopedSignalHandler {
public:
ScopedSignalHandler(int signal_number, void (*handler)(int), int sa_flags = 0)
: signal_number_(signal_number) {
- sigemptyset(&action_.sa_mask);
+ memset(&action_, 0, sizeof(action_));
action_.sa_flags = sa_flags;
action_.sa_handler = handler;
sigaction(signal_number_, &action_, &old_action_);
}
+ ScopedSignalHandler(int signal_number, void (*action)(int, siginfo_t*, void*),
+ int sa_flags = SA_SIGINFO)
+ : signal_number_(signal_number) {
+ memset(&action_, 0, sizeof(action_));
+ action_.sa_flags = sa_flags;
+ action_.sa_sigaction = action;
+ sigaction(signal_number_, &action_, &old_action_);
+ }
+
~ScopedSignalHandler() {
sigaction(signal_number_, &old_action_, NULL);
}