Skip to content

Commit

Permalink
Address requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cvonelm committed Feb 5, 2024
1 parent b30ece8 commit c572212
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/lo2s/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/monitor/process_monitor_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace monitor

[[noreturn]] static void run_command(const std::vector<std::string>& 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);
Expand Down
3 changes: 2 additions & 1 deletion src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,15 @@ 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;

if (current.rlim_cur == 0)
{
getrlimit(RLIMIT_NOFILE, &current);
}

return current;
}

Expand Down

0 comments on commit c572212

Please sign in to comment.