File descriptor limit

There is several limits a process is restricted to:

Limits for all open files in the system, or limits for number of files open in a process:

OpenBSD has 2 sysctl's that allow one control over amount of files in the system: There is kern.maxfiles which is setable at boot, and there is kern.nfiles which displays the number of open file descriptors in the system currently. For the process there is another set of limits that one should be aware of: $ ulimit -n 64

$ ulimit -Hn 1024

This displays the soft and hard limits respectively. One can set the soft limit up to the hard limit but not beyond unless you're root. The default hard limit is compiled into the kernel at compile time and is defined as the following in /usr/include/sys/param.h as NOFILE_MAX:


 * 1) define NOFILE_MAX     1024            /* max open files per process (hard) */

Only root can go set the hardlimit above 1024 and the limit to this is kern.maxfiles. The hardlimit can also be set in the /etc/login.conf file as openfiles-max. The softlimit is definable in the said file as openfiles-cur.

FreeBSD is different: