From a033bb5748eede6e220aa549236e046c46dbd4ae Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 11 Sep 2014 16:21:13 +0100 Subject: [PATCH 1/4] On Linux, call prctl to disable core dumps Whenever I forget to turn off corekeeper, the regression tests take ages to record all test-segfault's crashes. --- configure.ac | 4 ++++ test/test-segfault.c | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index cbaf874..471a2c4 100644 --- a/configure.ac +++ b/configure.ac @@ -598,6 +598,10 @@ if test "x$ac_cv_header_syslog_h" = "xyes"; then AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include ]]) fi +# For test-segfault.c +AC_CHECK_HEADERS_ONCE([sys/prctl.h]) +AC_CHECK_FUNCS_ONCE([prctl raise]) + #### Check for broken poll; taken from Glib's configure AC_MSG_CHECKING([for broken poll]) diff --git a/test/test-segfault.c b/test/test-segfault.c index 329a21f..c062ce1 100644 --- a/test/test-segfault.c +++ b/test/test-segfault.c @@ -9,18 +9,34 @@ #include #endif +#ifdef HAVE_SYS_PRCTL_H +#include +#endif + int main (int argc, char **argv) { char *p; #if 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 + +#ifdef HAVE_RAISE raise (SIGSEGV); #endif p = NULL; -- 2.1.0