summaryrefslogtreecommitdiff
path: root/test/test-segfault.c
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2016-05-18 18:14:16 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2016-05-18 18:14:16 +0100
commit5602ef4bf2a06771412fb4ce34e38bf967e018e6 (patch)
tree4535e35e360e0f53990c3e32034b159b2e26f9cd /test/test-segfault.c
parentaa44956ef6b928534e2b93a0ddaaf7b4fbe32651 (diff)
parent78362cfc62ebc5af8b529048b2e2aec0f977ceeb (diff)
downloaddbus-5602ef4bf2a06771412fb4ce34e38bf967e018e6.tar.gz
Merge branch 'dbus-1.10' into dbus-1.10-ci
Diffstat (limited to 'test/test-segfault.c')
-rw-r--r--test/test-segfault.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test-segfault.c b/test/test-segfault.c
index c062ce1c..b6c0f8ad 100644
--- a/test/test-segfault.c
+++ b/test/test-segfault.c
@@ -13,11 +13,37 @@
#include <sys/prctl.h>
#endif
+#ifdef DBUS_WIN
+#include <stdio.h>
+#include <windows.h>
+
+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, };