root/library/tests/unittest-cpp/Posix/SignalTranslator.cpp @ 742

Revision 706, 1.0 kB (checked in by smidl, 15 years ago)

eol-native

  • Property svn:eol-style set to native
Line 
1#include "SignalTranslator.h"
2
3namespace UnitTest {
4
5sigjmp_buf* SignalTranslator::s_jumpTarget = 0;
6
7namespace {
8
9void SignalHandler ( int sig ) {
10        siglongjmp ( *SignalTranslator::s_jumpTarget, sig );
11}
12
13}
14
15
16SignalTranslator::SignalTranslator() {
17        m_oldJumpTarget = s_jumpTarget;
18        s_jumpTarget = &m_currentJumpTarget;
19
20        struct sigaction action;
21        action.sa_flags = 0;
22        action.sa_handler = SignalHandler;
23        sigemptyset ( &action.sa_mask );
24
25        sigaction ( SIGSEGV, &action, &m_old_SIGSEGV_action );
26        sigaction ( SIGFPE , &action, &m_old_SIGFPE_action );
27        sigaction ( SIGTRAP, &action, &m_old_SIGTRAP_action );
28        sigaction ( SIGBUS , &action, &m_old_SIGBUS_action );
29        sigaction ( SIGILL , &action, &m_old_SIGBUS_action );
30}
31
32SignalTranslator::~SignalTranslator() {
33        sigaction ( SIGILL , &m_old_SIGBUS_action , 0 );
34        sigaction ( SIGBUS , &m_old_SIGBUS_action , 0 );
35        sigaction ( SIGTRAP, &m_old_SIGTRAP_action, 0 );
36        sigaction ( SIGFPE , &m_old_SIGFPE_action , 0 );
37        sigaction ( SIGSEGV, &m_old_SIGSEGV_action, 0 );
38
39        s_jumpTarget = m_oldJumpTarget;
40}
41
42
43}
Note: See TracBrowser for help on using the browser.