?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  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_SIGILL_action  );
  32.    }
  33.  
  34.    SignalTranslator::~SignalTranslator()
  35.    {
  36.       sigaction( SIGILL, &m_old_SIGILL_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. }
  47.