Skip to content

Commit

Permalink
read hard limit via getrlimit() first and only update soft limit
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed Nov 10, 2022
1 parent 5e2c36e commit 94679d0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/chia_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,13 @@ int main(int argc, char** argv)
if(true) {
// try to increase the open file limit
::rlimit the_limit;
the_limit.rlim_cur = num_files_max + 10;
the_limit.rlim_max = num_files_max + 10;
if(setrlimit(RLIMIT_NOFILE, &the_limit)) {
std::cout << "Warning: setrlimit() failed!" << std::endl;
if(getrlimit(RLIMIT_NOFILE, &the_limit) == 0) {
the_limit.rlim_cur = num_files_max + 10;
if(setrlimit(RLIMIT_NOFILE, &the_limit)) {
std::cout << "Warning: setrlimit() failed!" << std::endl;
}
} else {
std::cout << "Warning: getrlimit() failed!" << std::endl;
}
}
#endif
Expand Down

0 comments on commit 94679d0

Please sign in to comment.