Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix rlimit setting of RLIM_NOFILE on OSX #14054

Merged
merged 1 commit into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/pal/src/file/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3521,6 +3521,9 @@ DWORD FILEGetLastErrorFromErrno( void )
case EIO:
dwRet = ERROR_WRITE_FAULT;
break;
case EMFILE:
dwRet = ERROR_TOO_MANY_OPEN_FILES;
break;
case ERANGE:
dwRet = ERROR_BAD_PATHNAME;
break;
Expand Down
8 changes: 8 additions & 0 deletions src/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,14 @@ static BOOL INIT_IncreaseDescriptorLimit(void)
// Set our soft limit for file descriptors to be the same
// as the max limit.
rlp.rlim_cur = rlp.rlim_max;
#ifdef __APPLE__
// Based on compatibility note in setrlimit(2) manpage for OSX,
// trim the limit to OPEN_MAX.
if (rlp.rlim_cur > OPEN_MAX)
{
rlp.rlim_cur = OPEN_MAX;
}
#endif
result = setrlimit(RLIMIT_NOFILE, &rlp);
if (result != 0)
{
Expand Down