Friday, April 26, 2013

File Descriptors

A file descriptor is a handle created by a process when a file is opened. A new descriptor is created each time the file is opened. It is associated with a file object which includes information such as the mode in which the file was opened and the offset pointer where the next operation will begin. This information is called the context of the file.

File descriptors are retired when the file is closed or the process terminates. Opens always choose the lowest-numbered file descriptor available. Available file descriptors are allocated as follows (both parameters have a maximum setting of 65536 in current versions of Solaris 10):

  • rlim_fd_cur: Prior to Solaris 10, it was dangerous to set this value higher than 256 due to limitations with the stdio library. If programs require more than 256 file descriptors, they should use setrlimit directly.

  • rlim_fd_max: Prior to Solaris 10, it was dangerous to set this value higher than 1024 due to limitations with select. If programs require more than 1024 file descriptors, they should use setrlimit directly.

No comments: