1 /* This is simply a process that segfaults */
9 #include <sys/resource.h>
12 #ifdef HAVE_SYS_PRCTL_H
13 #include <sys/prctl.h>
20 #include <dbus/dbus-macros.h>
22 int exception_handler (LPEXCEPTION_POINTERS p) _DBUS_GNUC_NORETURN;
24 /* Explicit Windows exception handlers needed to supress OS popups */
26 exception_handler(LPEXCEPTION_POINTERS p)
28 fprintf(stderr, "test-segfault: raised fatal exception as intended\n");
29 ExitProcess(0xc0000005);
34 main (int argc, char **argv)
39 /* Disable Windows popup dialog when an app crashes so that app quits
40 * immediately with error code instead of waiting for user to dismiss
42 DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
43 SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
44 /* Disable "just in time" debugger */
45 SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler);
49 /* No core dumps please, we know we crashed. */
50 struct rlimit r = { 0, };
52 getrlimit (RLIMIT_CORE, &r);
54 setrlimit (RLIMIT_CORE, &r);
57 #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
58 /* Really, no core dumps please. On Linux, if core_pattern is
59 * set to a pipe (for abrt/apport/corekeeper/etc.), RLIMIT_CORE of 0
60 * is ignored (deliberately, so people can debug init(8) and other
61 * early stuff); but Linux has PR_SET_DUMPABLE, so we can avoid core
63 prctl (PR_SET_DUMPABLE, 0, 0, 0, 0);