Calls method of FatalConditionHandler (to avoid warnings)

This commit is contained in:
Phil Nash 2014-10-02 18:28:45 +01:00
parent 8ec9a5a547
commit b1936d3b0e
2 changed files with 12 additions and 3 deletions

View File

@ -58,14 +58,22 @@ namespace Catch {
fatal( "<unknown signal>", -sig ); fatal( "<unknown signal>", -sig );
} }
FatalConditionHandler() { FatalConditionHandler() : m_isSet( true ) {
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
signal( signalDefs[i].id, handleSignal ); signal( signalDefs[i].id, handleSignal );
} }
~FatalConditionHandler() { ~FatalConditionHandler() {
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) reset();
signal( signalDefs[i].id, SIG_DFL );
} }
void reset() {
if( m_isSet ) {
for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i )
signal( signalDefs[i].id, SIG_DFL );
m_isSet = false;
}
}
bool m_isSet;
}; };
} // namespace Catch } // namespace Catch

View File

@ -296,6 +296,7 @@ namespace Catch {
void invokeActiveTestCase() { void invokeActiveTestCase() {
FatalConditionHandler fatalConditionHandler; // Handle signals FatalConditionHandler fatalConditionHandler; // Handle signals
m_activeTestCase->invoke(); m_activeTestCase->invoke();
fatalConditionHandler.reset();
} }
private: private: