From bddc0e7e1a1a1cd804903b8b563deeee5f7c829b Mon Sep 17 00:00:00 2001
From: Daniel Albers <daniel@lbers.com>
Date: Tue, 14 Apr 2009 11:43:33 +0200
Subject: [PATCH] Disable crashhandler if coredumps are enabled

Since the abilities of the internal Crashhandler are limited, it should only be used in cases where no corefiles get dumped.

Fixes #673
---
 src/common/quassel.cpp |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp
index 4be4db1..241b9d4 100644
--- a/src/common/quassel.cpp
+++ b/src/common/quassel.cpp
@@ -22,6 +22,7 @@
 
 #include <iostream>
 #include <signal.h>
+#include <sys/resource.h>
 
 #include <QCoreApplication>
 #include <QDateTime>
@@ -55,11 +56,20 @@ Quassel::Quassel() {
   // we have crashhandler for win32 and unix (based on execinfo).
   // on mac os we use it's integrated backtrace generator
 #if defined(Q_OS_WIN32) || (defined(HAVE_EXECINFO) && !defined(Q_OS_MAC))
-  signal(SIGABRT, handleSignal);
-  signal(SIGSEGV, handleSignal);
-#  ifndef Q_OS_WIN32
-  signal(SIGBUS, handleSignal);
-#  endif
+
+  // we only handle crashes ourselves if coredumps are disabled
+  struct rlimit *limit = (rlimit *) malloc(sizeof(struct rlimit));
+  int rc = getrlimit(RLIMIT_CORE, limit);
+
+  if ( rc == -1 || !((long)limit->rlim_cur > 0 || limit->rlim_cur == RLIM_INFINITY) ) {
+    signal(SIGABRT, handleSignal);
+    signal(SIGSEGV, handleSignal);
+#   ifndef Q_OS_WIN32
+    signal(SIGBUS, handleSignal);
+#   endif
+  }
+  free(limit);
+
 #endif
 }
 
-- 
1.6.0.4

