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

Last reviewed: December 18, 1997
Article ID: Q131969
2.60 UNIX kbenv kbprb kbcode

The information in this article applies to:

  • Microsoft FoxPro for UNIX, version 2.6

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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.