diff options
Diffstat (limited to 'src/common/util.cpp')
-rw-r--r-- | src/common/util.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/common/util.cpp b/src/common/util.cpp index 7d9d7b408..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); @@ -919,4 +935,23 @@ std::string get_nix_version_display_string() return {}; } } + + std::string glob_to_regex(const std::string &val) + { + std::string newval; + + bool escape = false; + for (char c: val) + { + if (c == '*') + newval += escape ? "*" : ".*"; + else if (c == '?') + newval += escape ? "?" : "."; + else if (c == '\\') + newval += '\\', escape = !escape; + else + newval += c; + } + return newval; + } } |