WSL: open file descriptor limits not updating or being overridden
Windows Version: Microsoft Windows [Version 10.0.14393]
Appending session required pam_limits.so to the /etc/pam.d/common-session and /etc/pam.d/common-session-noninteractive files, and then updating the /etc/security/limits.conf by appending:
* soft nofile 35000
* hard nofile 35000
and restarting Windows, still does not actually update the ulimit -n value (or ulimit -Hn). It is stuck at 2048 and I am wondering if it can even be changed or if it is being overridden by some process manager, script, or the like?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 2
- Comments: 15 (1 by maintainers)
I just found a “better” workaround.
We can use
prlimit -p PIDto set limits for other processes, if we allow that command (or wrap it in a script to further secure it) and execute it withsudoat init, we can effectively change the limits for the running shell.EG:
$$resolves to the current process PIDThen change it
And “reload” the shell
Verify
To make it permanent I added
sudo prlimit -p "$$" --nofile=10000:10000to my~/.zloginanduser ALL=(ALL) NOPASSWD: /usr/bin/prlimitsomewhere in thesudoers.dfolder@sunilmut Sure.
I’m using bash on windows to try to build a project with node and webpack. There are many file that are opened during that process. Even with my workaround to set limits in conf files and use su, I was unable to complete the build due to file limit.
That outputs the limit of a different shell (with a different
PID) than the one where you changed the limit withprlimit(1). That much is linux-behavior.Assuming setting the limit in
.profile, newspeak would be something like:Some kind of placeholder feature request to make the default
unlimitedwould probably not be out of line. Or yet anotherwsl.confthingy. Absent a more complete resolution #994, anyway.So I just ran into this today as well.
I found that with those settings, I could do
and for that session the ulimit would be set according to limits.conf
I don’t want to have to do that all the time though…