[EMFILE] Too many open files

Hi all,

We're getting this error (24: Too many open files) in a proxy server that we handle while trying to open a file.

Manpage for open() states that it returns this error when it reaches the max open files limit for the process, but we have these numbers:

Code:
# sysctl kern.maxfiles kern.maxfilesperproc kern.openfiles
kern.maxfiles: 1048576
kern.maxfilesperproc: 1048576
kern.openfiles: 58428

As you can see, we have less than 60 thousand open files at kernel level, and probably 99% of these is opened by our proxy process. So, how can the system return EMFILE when we are using mere 5% of the max limit?

I'm a little confused here :\. Any clues?
 
chatwizrd said:
Check ulimit -n

Hi, chat. Thanks for answering.

Unfortunatelly, i did it already:

Code:
# ulimit -n
1048576
# ulimit -Hn
1048576
# ulimit -Sn
1048576

I've also tried the getrlimit function from inside the process (written in C):

Code:
struct rlimit rl;
getrlimit(RLIMIT_NOFILE, &rl);

Both rl.rlim_cur and rl.rlim_max returns 1048576.

Don't know what else to try :(.
 
chatwizrd said:
You can change the defaults in /etc/login.conf

login.conf()

Yeah, this is what we have made so far:

Code:
default:\
...
        :cputime=unlimited:\
        :datasize=unlimited:\
        :stacksize=unlimited:\
        :memorylocked=unlimited:\
        :memoryuse=unlimited:\
        :filesize=unlimited:\
        :coredumpsize=unlimited:\
        [B]:openfiles=unlimited:[/B]\
        :maxproc=unlimited:\
        :sbsize=unlimited:\
        :vmemoryuse=unlimited:\
        :swapuse=unlimited:\
        :pseudoterminals=unlimited:\
...

The process is running as root, and still getting the error :(
 
User hasn't been seen for 6 years, this thread is almost 10 years old. Open a new thread with your issue.
 
Back
Top