From cbd4b34481bbac60bbd9909e77b09af1487351fd Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 9 May 2016 17:31:17 +0200 Subject: [PATCH] Suppress Windows popups and jit debugger when app crashes with exception. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95155 --- test/test-segfault.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test-segfault.c b/test/test-segfault.c index c062ce1..7e2e82a 100644 --- a/test/test-segfault.c +++ b/test/test-segfault.c @@ -13,11 +13,36 @@ #include #endif +#ifdef DBUS_WIN +#include + +int +exception_handler(LPEXCEPTION_POINTERS p); + +/* Explicit Windows exception handlers needed to supress OS popups */ +int +exception_handler(LPEXCEPTION_POINTERS p) +{ + fprintf(stderr, "test-segfault: raised fatal exception as intended\n"); + ExitProcess(0xc0000005); +} +#endif + int main (int argc, char **argv) { char *p; +#ifdef DBUS_WIN + /* Disable Windows popup dialog when an app crashes so that app quits + * immediately with error code instead of waiting for user to dismiss + * the dialog. */ + DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX); + SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX); + /* Disable "just in time" debugger */ + SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler); +#endif + #if HAVE_SETRLIMIT /* No core dumps please, we know we crashed. */ struct rlimit r = { 0, }; -- 2.6.6