Commit d76465f6 authored by T K Sourab's avatar T K Sourab

Cleanup enforce_infinite_rmlimits

: removed getrlimit()
: Added error description using strerror()
Signed-off-by: default avatarT K Sourab <sourabhtk37@gmail.com>
parent 28757c42
...@@ -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