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)