SunSolve Internal

Infodoc ID   Synopsis   Date
18455   How to increase the number of open files within an application   14 Apr 1999

Description Top

If an application runs out of file descriptors, there are several ways to
address this:

 - Reconfigure the kernel for more file descriptors (not recommended)

 - Increase the number of file descriptors from the shell which starts 
   the application

 - Increase the number of file descriptors from within the application itself.

This SRDB provides an example of how to peform the last function using the
setrlimit(2) system call. In this example, the number of open file descriptors
is set to 1024:

#include <sys/resource.h>
#include <stdlib.h>
#include <stdio.h>

main ()
{
   struct rlimit *rlp; 
   rlp = (rlimit *) malloc (sizeof (struct rlimit));

   if (getrlimit (RLIMIT_NOFILE, rlp) ) {
      perror ("getrlimit");
      exit (1);
   }
   rlp->rlim_cur = (rlim_t) 1024; 

   if ( setrlimit (RLIMIT_NOFILE, rlp) ) {
      perror ("setrlimit");
      exit (1);
   }
}
Product Area Kernel
Product System calls
OS Solaris 2.x
Hardware any

Top

SunWeb Home SunWeb Search SunSolve Home Simple Search

Sun Proprietary/Confidential: Internal Use Only
Feedback to SunSolve Team