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 /test/test-segfault.c | |
parent | 16d2453ffada1d0c84996f392c7e4cad091da715 (diff) | |
download | dbus-77327b7bd897985261315e38e8524c21c266b1f0.tar.gz |
_dbus_disable_crash_handling: Factor out from test-segfault
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'test/test-segfault.c')
-rw-r--r-- | test/test-segfault.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/test/test-segfault.c b/test/test-segfault.c index 8517dd6c..a11d45b2 100644 --- a/test/test-segfault.c +++ b/test/test-segfault.c @@ -5,63 +5,14 @@ #include <signal.h> #endif -#ifdef HAVE_SETRLIMIT -#include <sys/resource.h> -#endif - -#ifdef HAVE_SYS_PRCTL_H -#include <sys/prctl.h> -#endif - -#ifdef DBUS_WIN -#include <stdio.h> -#include <windows.h> - -#include <dbus/dbus-macros.h> - -int exception_handler (LPEXCEPTION_POINTERS p) _DBUS_GNUC_NORETURN; - -/* 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 +#include "dbus/dbus-sysdeps.h" 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 - -#ifdef HAVE_SETRLIMIT - /* No core dumps please, we know we crashed. */ - struct rlimit r = { 0, }; - - getrlimit (RLIMIT_CORE, &r); - r.rlim_cur = 0; - setrlimit (RLIMIT_CORE, &r); -#endif - -#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) - /* Really, no core dumps please. On Linux, if core_pattern is - * set to a pipe (for abrt/apport/corekeeper/etc.), RLIMIT_CORE of 0 - * is ignored (deliberately, so people can debug init(8) and other - * early stuff); but Linux has PR_SET_DUMPABLE, so we can avoid core - * dumps anyway. */ - prctl (PR_SET_DUMPABLE, 0, 0, 0, 0); -#endif + _dbus_disable_crash_handling (); #ifdef HAVE_RAISE raise (SIGSEGV); |