aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-08-15 17:15:49 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-08-15 17:15:49 -0500
commit1d2c08610bb9437174fa393c3f739ee6228fb4aa (patch)
tree42a301b30a2490fb6a9cc3e27aa4ee8fca52edde /src/common
parentMerge pull request #4130 (diff)
parentwallet: disable core dumps on startup in release mode (diff)
downloadmonero-1d2c08610bb9437174fa393c3f739ee6228fb4aa.tar.xz
Merge pull request #4136
4307489 wallet: disable core dumps on startup in release mode (moneromooo-monero)
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.cpp16
-rw-r--r--src/common/util.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp
index f644c573c..5e0d2726e 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);
diff --git a/src/common/util.h b/src/common/util.h
index 6ec901e7f..8815232e2 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -149,6 +149,8 @@ namespace tools
bool sanitize_locale();
+ bool disable_core_dumps();
+
bool on_startup();
/*! \brief Defines a signal handler for win32 and *nix