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

Revision 418, 1.1 kB (checked in by vbarta, 15 years ago)

#27: added UnitTest?++ to bdm sources, changed test_user_data to use it

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