Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Apr 1996 15:50:44 -0700 (MST)
From:      Terry Lambert <terry@lambert.org>
To:        trig@netlink.co.uk (Christiaan Keet)
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Limit of number of open files for a process?
Message-ID:  <199604252250.PAA25666@phaeton.artisoft.com>
In-Reply-To: <m0uCVWR-000DlFC@netlink.co.uk> from "Christiaan Keet" at Apr 25, 96 07:12:06 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> Is there a limit to the number of open files that one process can have at
> any one time?
> 
> I'm just switching over to FreeBSD from Linux where I experienced this
> problem in that it limits you to 256 open files per process :(
> Can this limit be set in FreeBSD? And if so... what is the top limit?

Yes.  There is a hard limit and there is a soft limit.

The soft limit can be changed by using the "limit" or "unlimit"
or other shell-specific command, since the program inherits the
value from the shell (process) from which it is run.

The Hard limit (and soft limit defaults, for daemons, etc.)
require you to recompile the kernel after modifying header
files.

NB: the header file limits are there for a reason for most limits,
like physical page table entries and fixed size kernel structure;
the per process open file table limit is there because the BASH
shell starts at the end of limit space and works back to avoid
fd collisions instead of Doing The Right Thing and changing the
fd used to open the shell script file *when* the collision
actually occurs.


Read /sys/i386/conf/LINT for details.


The top limit is limited by memory.


NB2: If you are using buffered I/O (stdio's 'f' functions, like
"fopen" instead of "open", "fread" instead of "read", etc.), stdio
has traditionally been limited to using 256 file descriptors.  This
is why most server programs do *not* use stdio.



					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199604252250.PAA25666>