My Oracle Support Banner

Solaris[TM] File descriptors - Solaris[TM] 2.4 through Solaris[TM] 11 (Doc ID 1005979.1)

Last updated on MARCH 16, 2023

Applies to:

Solaris Operating System - Version 8 to 11.4 [Release 8.0 to 11.0]
All Platforms
rlim_fd_max
rlim_fd_cur
FD_SETSIZE stdio

Goal

About File Descriptors

Processes interface with files through file-related system calls. The file-related system calls identify files by two means: their path name in the file system and a file descriptor. A file descriptor is an integer number identifying an open file within a process. Each process has a table of open files, starting at file descriptor 0 and progressing upward as more files are opened. A file descriptor can be obtained with the open() system call, which opens a file named by a path name and returns a file descriptor identifying the open file.

fd = open("/etc/passwd", flag, mode);

Once a file has been opened, a file descriptor can be used for operations on the file. The read(2) and write(2) operations provide basic file I/O, along with several other advanced mechanisms for performing more complex operations. A file descriptor is eventually closed by the close(2) system call or by the process' exit. By default, file descriptors 0, 1, and 2 are opened automatically by the C runtime library and represent the standard input, standard output, and standard error streams for a process.
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 and above, this can now be done through the /etc/system file.

The kernel establishes default hard and soft limits for the number of files a process can have opened at any one time. rlim_fd_max is the hard limit, and rlim_fd_cur is the current limit (or soft limit). A process can have up to rlim_fd_cur file descriptors and can increase the number up to rlim_fd_max. You can set these parameters system-wide by placing entries in the /etc/system file:

set rlim_fd_max=8192
set rlim_fd_cur=1024

You can also alter the per-process limits either directly from the command line with the limit(1) or ulimit(1) shell commands, or programmatically with setrlimit(2). The actual number of open files that a process can maintain is largely determined by the file APIs used. For 32-bit systems, the the stdio(3S) interfaces are used, the limit is 256 open files. This limit results from the data type used in the FILE structure for the actual file descriptor. An unsigned 8-bit data type, which has a range of values of 0-255, is used. Thus, the maximum number of file descriptors is limited to 256 for 32-bit stdio(3S)-based programs. For 64-bit systems(and 64-bit processes), the stdio(3S) limit is 64 Kbytes."

The select(3C) interface, which provides a mechanism for polling, imposes another API limit. select(3C) limits the number of open files to 1 Kbyte on 32-bit systems, with the exception of 32-bit Solaris 7 [and later]. In 32-bit Solaris 7, select(3C) can poll up to 64-Kbyte file descriptors. If you use file descriptors greater than 1-Kbyte with select(3C) on 32-Bit Solaris 7 [or later], then you must declare FD_SETSIZE in the program code. On 64-bit Solaris 7, a 64-bit process has a default file descriptor set size (FD_SETSIZE) of 64Kbytes. Table 11-2 summarizes file descriptor limitations.
The following table shows the default and maximum values for the soft
and hard limits.

OS VersionDefault Limit*1Default Hard Limit*1Max for stdioMax for select*2
Solaris 2.4-2.6 64 1024 256 1024
Solaris 7 (32-bit) 64 1024 256 65536 (with recompile)*2
Solaris 7 (64-bit) 64 1024 256 65536
Solaris 8 (32-bit) 256 1024 256 65536 (with recompile)*2
Solaris 8 (64-bit) 256 1024 256 65536
Solaris 9 (32-bit) 256 65536 256 65536(with recompile)*2
Solaris 9 (64-bit) 256 65536 256 65535
Solaris 10 (64-bit) 256 65536 256*3 65536
Solaris 11.0 - 11.3 256 65536

256*3 (for 32bit) / File Descriptor Limit (for 64bit)

65536
Solaris 11.4 though SRU  26 256 65536 File Descriptor Limit*3 65536
Solaris 11.4 SRU 27 4095 65535 File Descriptor Limit*3 65536


The soft limit (default limit) has to remain lower or equal to the hard limit.

*1 See "The procedure to change file descriptor limit" below.
*2 Refers to paragraph above.
*3 See the note below regarding stdio routines( fopen and related ANSI C standard functions )

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
 About File Descriptors
Solution
 The procedure to change file descriptor limit in Solaris 2.4 through 2.9
 Note that the stdio routines( fopen and related ANSI C standard functions )
 The procedure to change file descriptor limit in Solaris 10 and later releases
 Important Note when looking at truss:

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.