Difference between revisions of "File descriptor limit"

From Hackepedia
Jump to navigationJump to search
 
 
(2 intermediate revisions by the same user not shown)
Line 10: Line 10:
 
  1024
 
  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 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:
+
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:
  
 
  #define NOFILE_MAX      1024            /* max open files per process (hard) */
 
  #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.
+
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:
 
[[FreeBSD]] is different:

Latest revision as of 05:58, 6 October 2005

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:

#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: