MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLGetRemainingFileDescriptorCount

Function CPLGetRemainingFileDescriptorCount

port/cpl_conv.cpp:4036–4059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4034#if defined(__FreeBSD__)
4035
4036int CPLGetRemainingFileDescriptorCount()
4037{
4038 struct rlimit limitNumberOfFilesPerProcess;
4039 if (getrlimit(RLIMIT_NOFILE, &limitNumberOfFilesPerProcess) != 0)
4040 {
4041 return -1;
4042 }
4043 const int maxNumberOfFilesPerProcess =
4044 static_cast<int>(limitNumberOfFilesPerProcess.rlim_cur);
4045
4046 const pid_t pid = getpid();
4047 int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC,
4048 static_cast<int>(pid)};
4049
4050 size_t len = 0;
4051
4052 if (sysctl(mib, 4, nullptr, &len, nullptr, 0) == -1)
4053 {
4054 return -1;
4055 }
4056
4057 return maxNumberOfFilesPerProcess -
4058 static_cast<int>(len / sizeof(struct kinfo_file));
4059}
4060
4061#else
4062

Callers 3

TEST_FFunction · 0.85
GetMaxChildCountMethod · 0.85

Calls 3

VSIOpenDirFunction · 0.85
VSIGetNextDirEntryFunction · 0.85
VSICloseDirFunction · 0.85

Tested by 1

TEST_FFunction · 0.68