From 87a7546638e6dea32c55d589ef35928d3373ab97 Mon Sep 17 00:00:00 2001 From: yao-msft <50888816+yao-msft@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:30:00 -0700 Subject: [PATCH] Increase file descriptor limit in wsla init (#13524) --- src/linux/init/WSLAInit.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/linux/init/WSLAInit.cpp b/src/linux/init/WSLAInit.cpp index 5999469..d757de0 100644 --- a/src/linux/init/WSLAInit.cpp +++ b/src/linux/init/WSLAInit.cpp @@ -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)