From 43074891479b4883645b06c4cc5341469d9cd9cd Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 15 Jul 2018 13:20:36 +0100 Subject: wallet: disable core dumps on startup in release mode --- src/common/util.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/common/util.cpp') diff --git a/src/common/util.cpp b/src/common/util.cpp index 7d9d7b408..be49c77c3 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -37,6 +37,7 @@ #ifdef __GLIBC__ #include #include +#include #include #include #include @@ -682,6 +683,21 @@ std::string get_nix_version_display_string() static void setup_crash_dump() {} #endif + bool disable_core_dumps() + { +#ifdef __GLIBC__ + // disable core dumps in release mode + struct rlimit rlimit; + rlimit.rlim_cur = rlimit.rlim_max = 0; + if (setrlimit(RLIMIT_CORE, &rlimit)) + { + MWARNING("Failed to disable core dumps"); + return false; + } +#endif + return true; + } + bool on_startup() { mlog_configure("", true); -- cgit v1.2.3