forked from esy/esy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increase RLIMIT_NOFILE locally on Linux and macOS
* closes esy#1057
- Loading branch information
1 parent
23fa821
commit 4648673
Showing
5 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <caml/mlvalues.h> | ||
|
||
#if __APPLE__ || __linux__ | ||
#include <sys/resource.h> | ||
#endif | ||
|
||
#define MIN_NOFILE 4096 | ||
|
||
CAMLprim value | ||
esy_ensure_minimum_file_descriptors(value unit) { | ||
#if __APPLE__ || __linux__ | ||
struct rlimit limits; | ||
getrlimit(RLIMIT_NOFILE, &limits); | ||
if (limits.rlim_cur < MIN_NOFILE) { | ||
limits.rlim_cur = MIN_NOFILE; | ||
setrlimit(RLIMIT_NOFILE, &limits); | ||
} | ||
#endif | ||
return Val_unit; | ||
} |