Commit 3a9c9d0f authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #391 from sourabhtk37/enforce_rlimit_cleanup#240

Cleanup enforce_infinite_rlimits
parents a261317b d76465f6
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <signal.h> #include <signal.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include "bpforc.h" #include "bpforc.h"
#include "bpftrace.h" #include "bpftrace.h"
...@@ -42,16 +43,13 @@ void usage() ...@@ -42,16 +43,13 @@ void usage()
static void enforce_infinite_rlimit() { static void enforce_infinite_rlimit() {
struct rlimit rl = {}; struct rlimit rl = {};
if (getrlimit(RLIMIT_MEMLOCK, &rl) != 0) { int err;
std::cerr << "Warning: couldn't set RLIMIT for bpftrace. " <<
"If your program is not loading, you can try " <<
"\"ulimit -l 8192\" to fix the problem" << std::endl;
return;
}
rl.rlim_max = RLIM_INFINITY; rl.rlim_max = RLIM_INFINITY;
rl.rlim_cur = rl.rlim_max; rl.rlim_cur = rl.rlim_max;
if (setrlimit(RLIMIT_MEMLOCK, &rl) != 0) err = setrlimit(RLIMIT_MEMLOCK, &rl);
std::cerr << "Warning: couldn't set RLIMIT for bpftrace. " << if (err)
std::cerr << std::strerror(err)<<": couldn't set RLIMIT for bpftrace. " <<
"If your program is not loading, you can try " << "If your program is not loading, you can try " <<
"\"ulimit -l 8192\" to fix the problem" << std::endl; "\"ulimit -l 8192\" to fix the problem" << std::endl;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment