summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-09-15 11:50:48 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-09-15 11:50:48 +0100
commitae50d46ff26de73ec5f8390abcca879340cb0962 (patch)
tree3644d29665f3fadd0d686d08dbfa74eb9e95fa8a /test
parent467f7a6d426a37ddc0f9401f592facad3d003dfa (diff)
downloaddbus-ae50d46ff26de73ec5f8390abcca879340cb0962.tar.gz
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. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83772 Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
Diffstat (limited to 'test')
-rw-r--r--test/test-segfault.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/test-segfault.c b/test/test-segfault.c
index 329a21fd..c062ce1c 100644
--- a/test/test-segfault.c
+++ b/test/test-segfault.c
@@ -9,18 +9,34 @@
#include <sys/resource.h>
#endif
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#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;