Increase file descriptor limit in wsla init (#13524)

This commit is contained in:
yao-msft 2025-09-26 11:30:00 -07:00 committed by GitHub
parent 7e7bc436df
commit 87a7546638
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -637,7 +637,20 @@ int WSLAEntryPoint(int Argc, char* Argv[])
g_LogFd = 3;
}
//
// Increase the soft and hard limit for number of open file descriptors.
// N.B. the soft limit shouldn't be too high. See https://github.com/microsoft/WSL/issues/12985 .
//
rlimit Limit{};
Limit.rlim_cur = 1024 * 10;
Limit.rlim_max = 1024 * 1024;
if (setrlimit(RLIMIT_NOFILE, &Limit) < 0)
{
LOG_ERROR("setrlimit(RLIMIT_NOFILE) failed {}", errno);
return -1;
}
Limit.rlim_cur = 0x4000000;
Limit.rlim_max = 0x4000000;
if (setrlimit(RLIMIT_MEMLOCK, &Limit) < 0)