[Mobies-commit] [commit] r3902 - UDM/trunk/tests/test_ns

ksmyth at redhat1.isis.vanderbilt.edu ksmyth at redhat1.isis.vanderbilt.edu
Wed Sep 21 09:28:50 CDT 2011


Author: ksmyth
Date: Wed Sep 21 09:28:50 2011
New Revision: 3902

Log:
Uninstall hooks

Modified:
   UDM/trunk/tests/test_ns/main.cpp

Modified: UDM/trunk/tests/test_ns/main.cpp
==============================================================================
--- UDM/trunk/tests/test_ns/main.cpp	Tue Sep 20 15:41:04 2011	(r3901)
+++ UDM/trunk/tests/test_ns/main.cpp	Wed Sep 21 09:28:50 2011	(r3902)
@@ -21,15 +21,27 @@
 {
 	DebugBreak();
 }
+
+struct _CrtHooksRAII {
+	_CrtHooksRAII() {
+		oldAbrtHandler = signal(SIGABRT, &AbrtHandler);
+		_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
+		_set_abort_behavior(0, _WRITE_ABORT_MSG);
+		oldHook = _CrtSetReportHook(&CrtReportHook);
+	}
+	~_CrtHooksRAII() {
+		_CrtSetReportHook(oldHook);
+		signal(SIGABRT, oldAbrtHandler);
+	}
+	_CRT_REPORT_HOOK oldHook;
+	void (__cdecl *oldAbrtHandler)(int);
+};
 #endif
 
 int main(int argc, char* argv[])
 {
 #ifdef _WIN32
-	signal(SIGABRT, &AbrtHandler);
-	_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
-	_set_abort_behavior(0, _WRITE_ABORT_MSG);
-	_CrtSetReportHook(&CrtReportHook);
+	_CrtHooksRAII hooks;
 #endif
 
 	CPPUNIT_NS::Test *suite = CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();


More information about the Mobies-commit mailing list