sysctl maxfiles

Peter Jeremy peterjeremy at
Sat Sep 27 21:46:32 UTC 2008

On 2008-Sep-27 22:14:09 +0200, Miroslav Lachman <000.fbsd at> wrote:
>root at roxy ~/# fstat -u www | wc -l
>     9931
>root at roxy ~/# fstat -u root | wc -l
>      718
>root at roxy ~/# fstat | grep httpd | wc -l
>     6379
>root at roxy ~/# fstat | grep httpd | wc -l
>     6002
>root at roxy ~/# fstat -u www | wc -l
>     4691
>root at roxy ~/# sysctl kern.openfiles
>kern.openfiles: 846

kern.openfiles reflects the total number of open file structures
within the kernel, whereas fstat (and lsof) report both open files
and vnodes associated with each process.  The differences are
1) File structures are shared via fork() etc so the same file structure
   can be reported multiple times.
2) fstat reports executable name, working directory and root

Open files in fstat can be detected because they have numeric values
(possibly with a '*' appended) in the FD column.  Unfortunately, there
doesn't appear to be any easy way to detect shared file structures
(for inode-based files) using either fstat or lsof.

In the case of apache, there are at least 6 file structures shared
by each httpd process (and it looks like it might be about 15).

Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url :

More information about the freebsd-stable mailing list