diff --git a/include/lo2s/util.hpp b/include/lo2s/util.hpp index 3cc0f294..2d85569f 100644 --- a/include/lo2s/util.hpp +++ b/include/lo2s/util.hpp @@ -116,7 +116,7 @@ void try_pin_to_scope(ExecutionScope scope); int get_cgroup_mountpoint_fd(std::string cgroup); void bump_rlimit_fd(); -struct rlimit save_rlimit_fd(); +struct rlimit initial_rlimit_fd(); Thread gettid(); diff --git a/src/main.cpp b/src/main.cpp index b48ff637..83c7eaec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,7 +35,7 @@ int main(int argc, const char** argv) // do not use select(), so we can safely bump the limit, but whatever command we are running // under lo2s might (and resource limits are preserved accross fork()) so preserve it here so // that we can restore it later - lo2s::save_rlimit_fd(); + lo2s::initial_rlimit_fd(); lo2s::bump_rlimit_fd(); try diff --git a/src/monitor/process_monitor_main.cpp b/src/monitor/process_monitor_main.cpp index 12238809..caa98829 100644 --- a/src/monitor/process_monitor_main.cpp +++ b/src/monitor/process_monitor_main.cpp @@ -55,8 +55,8 @@ namespace monitor [[noreturn]] static void run_command(const std::vector& command_and_args) { - struct rlimit saved_rlimit = save_rlimit_fd(); - setrlimit(RLIMIT_OFILE, &saved_rlimit); + struct rlimit initial_rlimit = initial_rlimit_fd(); + setrlimit(RLIMIT_NOFILE, &initial_rlimit); /* kill yourself if the parent dies */ prctl(PR_SET_PDEATHSIG, SIGHUP); diff --git a/src/util.cpp b/src/util.cpp index da22a1d9..a71dcbff 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -367,7 +367,7 @@ std::string get_nec_thread_comm(Thread thread) return std::accumulate(args.begin(), args.end(), std::string("")); } -struct rlimit save_rlimit_fd() +struct rlimit initial_rlimit_fd() { static struct rlimit current; @@ -375,6 +375,7 @@ struct rlimit save_rlimit_fd() { getrlimit(RLIMIT_NOFILE, ¤t); } + return current; }