/* exception.c - Don Yang (uguu.org) Exception handler test. 09/11/04 */ #ifdef _WIN32 #include #include #else #include #include #include #endif #ifdef _WIN32 static LONG WINAPI ExceptionHandler(/*@unused@*/LPEXCEPTION_POINTERS p) { (void)puts("fatal exception caught"); ExitProcess(0); return EXCEPTION_EXECUTE_HANDLER; } static void TrapExceptions(void) { (void)SetUnhandledExceptionFilter(ExceptionHandler); } #else static void ExceptionHandler(/*@unused@*/int s) { (void)puts("fatal exception caught"); exit(EXIT_FAILURE); } static void TrapExceptions(void) { (void)signal(SIGSEGV, ExceptionHandler); } #endif int main(void) { TrapExceptions(); *((int*)0) = 0; return 0; }