RLIMIT_NOFILE
One more than the highest file descriptor number the process may open.
- Resource number
- 7
- Row in /proc/PID/limits
- Max open files
- bash ulimit flag
- ulimit -n
- Unit in /proc/PID/limits
- files
- Group
- Files and descriptors
What happens at the limit
The soft limit of 1024 is the one that bites, and a service started from a script that runs `ulimit -n 1024` gets it whatever the box allows. The hard limit cannot be set above /proc/sys/fs/nr_open. Passing descriptors over SCM_RIGHTS can also hit it: see the sendmsg(2) card for the Linux 4.5 in-flight descriptor rule.
Check a running process with grep -i "Max open files" /proc/PID/limits, or paste the whole file into the limits reader. Inspect or change one on a live process with prlimit --pid PID(util-linux).
Syscall cards that mention it
- SCM_RIGHTSLinux · IPC
Pass open file descriptors to another process over a UNIX domain socket.
Rod on this
Check the process, not your shell
Your login shell and the service can have very different limits. Read the running process, count what it holds, and change it live with prlimit while you fix the unit file.
grep 'open files' /proc/PID/limits ls /proc/PID/fd | wc -l prlimit --pid PID --nofile=65536:65536 # raising the hard limit needs CAP_SYS_RESOURCE cat /proc/sys/fs/nr_open # ceiling for the hard limit
Sources
Resource numbers are from asm-generic/resource.h; a few architectures (Alpha, MIPS, SPARC) number some limits differently. The list of syscall cards is matched by name from the card text on this site, not from the kernel source. Spot one that's wrong? Tell Rod.