diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-07-15 13:20:36 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-08-12 16:28:10 +0000 |
commit | 43074891479b4883645b06c4cc5341469d9cd9cd (patch) | |
tree | 64ef46421d272b30585c560fbe9807187319363f /src/common/util.cpp | |
parent | Merge pull request #4094 (diff) | |
download | monero-43074891479b4883645b06c4cc5341469d9cd9cd.tar.xz |
wallet: disable core dumps on startup in release mode
Diffstat (limited to '')
-rw-r--r-- | src/common/util.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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 <sys/types.h> #include <sys/stat.h> +#include <sys/resource.h> #include <ustat.h> #include <unistd.h> #include <dirent.h> @@ -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); |