Subject : How to change file descriptor limit in Solaris 2.4

Description :


In 2.3 and earlier releases, the only way to permanently change the
default number of file descriptors that a process can open
was to use adb on the kernel.  In 2.4, this can now be done through the
/etc/system file.

SOLUTION SUMMARY:

There is now a way to change the number of file descriptors available
in 2.4.  The information below is from uts/common/conf/param.c in the
source:

        /*
         * symbols added to make changing max-file-descriptors
         * simple via /etc/system
         */
        #define RLIM_FD_CUR 0x40
        #define RLIM_FD_MAX 0x400

        int rlim_fd_cur = RLIM_FD_CUR;
        int rlim_fd_max = RLIM_FD_MAX;

The "rlim_fd_cur" variable corresponds to the soft limit, and the
"rlim_fd_max" is the hard limit.

Alter the number of file descriptors on a 2.4 system by adding the
following line to the /etc/system file:

        set rlim_fd_cur=0x80

Since 0x80 = 128, the above line changes the number of file descriptors
to 128 after a reboot.  By the way, boot -r is not needed.

However, before doing this, note the following:

1. Stdio routines are limited to using file descriptors 0 - 255.  Even
though you can set the limit higher than 256, if fopen() cannot get a
file descriptor lower than 256, the fopen() fails.  This can be a
problem if you have other routines using open() directly.  For example,
if you open 256 files with open() without closing any, you won't be able
to open any files at all with fopen(), because all the low-numbered file 
descriptors have been used up.

2. It is somewhat dangerous to set the fd limits higher than 1024.
There are some structures defined in the system (like fd_set in
) that assume that the maximum fd is 1023.  If the
program uses an fd larger than this with the macros and routines that
access this structure (like FD_SET()), it will corrupt its memory
space because it will modify memory outside the bounds of the structure.
This structure is used specifically by the select() routine, and
indirectly by many library calls that use select().


Revision History

ÀÛ¼ºÀÏÀÚ : 96.08.30
ÀÛ¼ºÀÚ : À̹ÎÈ£

¼öÁ¤ÀÏÀÚ :
¼öÁ¤ÀÚ :