summaryrefslogtreecommitdiff
path: root/test/test-segfault.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2014-10-01 19:45:00 +0100
committerSimon McVittie <smcv@debian.org>2014-10-01 19:45:00 +0100
commit255f62947424c4622609eb93ed53371dda28aac9 (patch)
tree6f8c5dbb96e48fa2d40919bb3282fae0b6d953de /test/test-segfault.c
parentc03b8e681afa8e45977fc74e30142497939b47d1 (diff)
parent33ee25f98af863e9355fd53b9184c0b798343b89 (diff)
downloaddbus-upstream/1.9.0.tar.gz
Imported Upstream version 1.9.0upstream/1.9.0
Diffstat (limited to 'test/test-segfault.c')
-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;