mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 00:37:43 +00:00
wallet: disable core dumps on startup in release mode
This commit is contained in:
parent
eed4dba880
commit
4307489147
4 changed files with 24 additions and 0 deletions
|
@ -37,6 +37,7 @@
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include <ustat.h>
|
#include <ustat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -682,6 +683,21 @@ std::string get_nix_version_display_string()
|
||||||
static void setup_crash_dump() {}
|
static void setup_crash_dump() {}
|
||||||
#endif
|
#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()
|
bool on_startup()
|
||||||
{
|
{
|
||||||
mlog_configure("", true);
|
mlog_configure("", true);
|
||||||
|
|
|
@ -149,6 +149,8 @@ namespace tools
|
||||||
|
|
||||||
bool sanitize_locale();
|
bool sanitize_locale();
|
||||||
|
|
||||||
|
bool disable_core_dumps();
|
||||||
|
|
||||||
bool on_startup();
|
bool on_startup();
|
||||||
|
|
||||||
/*! \brief Defines a signal handler for win32 and *nix
|
/*! \brief Defines a signal handler for win32 and *nix
|
||||||
|
|
|
@ -51,6 +51,9 @@ bool isAddressLocal(const std::string &address)
|
||||||
void onStartup()
|
void onStartup()
|
||||||
{
|
{
|
||||||
tools::on_startup();
|
tools::on_startup();
|
||||||
|
#ifdef NDEBUG
|
||||||
|
tools::disable_core_dumps();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,9 @@ namespace wallet_args
|
||||||
|
|
||||||
std::string lang = i18n_get_language();
|
std::string lang = i18n_get_language();
|
||||||
tools::on_startup();
|
tools::on_startup();
|
||||||
|
#ifdef NDEBUG
|
||||||
|
tools::disable_core_dumps();
|
||||||
|
#endif
|
||||||
tools::set_strict_default_file_permissions(true);
|
tools::set_strict_default_file_permissions(true);
|
||||||
|
|
||||||
epee::string_tools::set_module_name_and_folder(argv[0]);
|
epee::string_tools::set_module_name_and_folder(argv[0]);
|
||||||
|
|
Loading…
Reference in a new issue