diff options
author | Simon McVittie <smcv@collabora.com> | 2018-11-20 12:48:40 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2018-11-20 12:58:17 +0000 |
commit | 77327b7bd897985261315e38e8524c21c266b1f0 (patch) | |
tree | 8884e769491908e678464bc6085d055f882d3827 /dbus/dbus-sysdeps-util-win.c | |
parent | 16d2453ffada1d0c84996f392c7e4cad091da715 (diff) |
_dbus_disable_crash_handling: Factor out from test-segfault
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'dbus/dbus-sysdeps-util-win.c')
-rw-r--r-- | dbus/dbus-sysdeps-util-win.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index fc356908..0182b6b1 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -1688,3 +1688,27 @@ _dbus_win_stderr_win_error (const char *app, fprintf (stderr, "%s: %s: %s\n", app, message, error.message); dbus_error_free (&error); } + +static int exception_handler (LPEXCEPTION_POINTERS p) _DBUS_GNUC_NORETURN; + +static int +exception_handler (LPEXCEPTION_POINTERS p) +{ + ExitProcess (0xc0000005); +} + +/** + * Try to disable core dumps and similar special crash handling. + */ +void +_dbus_disable_crash_handling (void) +{ + /* 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); +} |