PRB: How to Troubleshoot 'Too many files open' Error

ID: Q131969

2.60 UNIX kbenv kbprb kbcode

The information in this article applies to:

SYMPTOMS

You receive the 'Too many files open' FoxPro error message and may then be dropped out of FoxPro to a system prompt.

CAUSE

This error is due to the fact that FoxPro for UNIX is requesting another file be opened by the operating system. Neither FoxPro for UNIX nor the operating system can open another file.

Another possible cause is that the kernel is misconfigured for NFILE, NOFILES, and/or FLCKREC parameters, or the kernel may be damaged in some way.

RESOLUTION

1. Check NFILE, NOFILES, and FLCKREC to make sure they are configured for

   at least the default values of:

   NFILE - 200
   NOFILES - 60
   FLCKREC - 100.

2. Run the C code listed in the "More Information" section. Then, attempt
   to run FoxPro again. If running the C code yields the 'lock failed'
   error, the operating system cannot open any additional files.

STATUS

This behavior is by design.

MORE INFORMATION

The following C code tests to see if both FoxPro for Unix and the operating system can open another file.

NOTE: You must have a Unix C compiler to compile this code to run the test.

#include <fcntl.h>

main() {
   int track[150];
   int i;
   struct flock lockstruct;

   for (i=0; i<150; i++)
   {
      track[i] = open("/dev/null", 0);
      if (track[i] < 0)
      {
         printf("open failed\n");
         break;
      }

      lockstruct.l_type = F_RDLCK;
      lockstruct.l_whence = 0;     // from start of file
      lockstruct.l_start = 0;
      lockstruct.l_len = 1;
      if (fcntl(track[i], F_SETLK, &lockstruct) == -1)
      {
         printf("lock failed\n");
         break;
      }
   }

   printf("Opened %d files\n",i);
}

WARNING: Microsoft provides this information "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Additional reference words: FoxUnix 2.60 KBCategory: kbenv kbprb kbcode KBSubcategory: FxenvOs

Last Reviewed: December 18, 1997