1

I found hard limit value in /proc/{pid}/limits match the output of ulimit -Hn while soft limit value doesn't

my example output:

tomcat@myLinux:/home/azhang$ ulimit -Sn
1024
tomcat@myLinux:/home/azhang$ ulimit -Hn
1048576
tomcat@myLinux:/home/azhang$ ulimit -n
1024

So soft limit is 1024

I have a tomcat running as tomcat user and i checked the limit of that process,

tomcat@myLinux:/home/azhang$ cat /proc/12257/limits 
Limit                     Soft Limit           Hard Limit           Units     
....
Max processes             31854                31854                processes 
Max open files            1048576              1048576              files     
Max locked memory         65536                65536                bytes     
....

The soft limit of process 12257(tomcat) is 1048576, same as hard limit and not 1024

Is it a bug of /proc/{pid}/limits?

actan
  • 111
  • 4
  • Did you run tomcat in the same session you exec `ulimit` command? – Romeo Ninov Jan 22 '19 at 10:08
  • not for my above environment. I tried in another server: first I try `ulimit -Sn` and I get **1024**, try `ulimit -Hn` and get **4096**, then I confirmed ulimit was not set in startup tomcat script like /etc/init.d/tomcat_8080, catalina.sh, setenv.sh and I started tomcat by `/etc/init.d/tomcat_8080 start`, then I get soft&hard limit of tomcat process both as **4096**, different machine but same case. – actan Jan 22 '19 at 10:35
  • It can be but. I can't get situation for such differences... – Romeo Ninov Jan 22 '19 at 10:41
  • So I think it you are changing process limit not the user limits from configuration itself, can you please try to filter from config if you are doing so? – asktyagi Apr 28 '19 at 13:32
  • I have the same problem. On a debian system, after reboot, checking the user running nginx: `ulimit -Hn` shows **1048576**, but `cat /proc//limits` shows a hard file limit of **4096**. ‍♂️ – Quinn Comendant Dec 16 '19 at 20:14
  • According this [this answer](https://serverfault.com/a/799592), the values in `/proc/{pid}/limits` are set by systemd, which require changing config in a systemd unit file. – Quinn Comendant Dec 16 '19 at 20:21

0 Answers0