comparison ext/UnitTest++/src/Posix/SignalTranslator.cpp @ 37:0d325e9d5953

added unittest++ files into ext. Not hooked into build scripts yet
author jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 12 Jul 2008 12:00:57 +0000
parents
children
comparison
equal deleted inserted replaced
36:6f1227f4932b 37:0d325e9d5953
1 #include "SignalTranslator.h"
2
3 namespace UnitTest {
4
5 sigjmp_buf* SignalTranslator::s_jumpTarget = 0;
6
7 namespace {
8
9 void SignalHandler (int sig)
10 {
11 siglongjmp(*SignalTranslator::s_jumpTarget, sig );
12 }
13
14 }
15
16
17 SignalTranslator::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
34 SignalTranslator::~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 }