Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!mit-eddie!genrad!decvax!tektronix!reed!psu-cs!omepd!perry From: perry@omepd.UUCP Newsgroups: comp.sys.ibm.pc Subject: Limits on MSDOS file handles Message-ID: <421@omepd> Date: Thu, 19-Feb-87 02:30:35 EST Article-I.D.: omepd.421 Posted: Thu Feb 19 02:30:35 1987 Date-Received: Fri, 20-Feb-87 07:18:31 EST References: <1500@im4u.UUCP> Sender: news@omepd Reply-To: perry@inteloa.intel.com (Perry The Cynic) Organization: Intel Corp., Hillsboro Lines: 51 Keywords: file handles Summary: There are TWO DIFFERENT limits on MSDOS file handles! In article <1500@im4u.UUCP> jai@im4u.UUCP (Jai Srinivasan) writes: >I have a C program run from a Procomm command file. The program >runs fine when called directly from DOS. When called by Procomm >from the command file, it exits saying that it cannot open a file. >Naturally, I suspected that Procomm left several files open before >executing the program; so I closed stdprn and stdaux at the start >of the program and tried it again. And got the same results. >Finally, I increased the number of FILES in CONFIG.SYS; the program >is executed properly now when called from Procomm. It seems that you and many others don't realize that MSDOS actually imposes TWO DIFFERENT kinds of limits on the number of file handles you can successfully open. These two limits are related but must be distinguished: First, there is a limit on the number of handles IN THE ENTIRE COMPUTER. This is what you set with the FILES=nnn directive; it puts a cap on the number of handles that can be simultaneously open IN ALL PROGRAMS TOGETHER. Second, there is a limit on the number of handles IN ONE PROGRAM. This limit is frozen solid at 20 (twenty) and cannot be changed (short of patching the MSDOS system files - not COMMAND). As long as you are running one program at a time (from COMMAND.COM), these two limits apply essentially to the same thing. This means that you can usually use the lesser of 20 and the FILES=nnn number. Note that a FILES argument of more than 20 makes no sense under these circumstances. If, however, you execute one program from another one (as from PROCOMM in your case), the FILES= limit applies to the TOTAL OF DIFFERENT HANDLES in both programs. Any files open in resident programs count toward the FILES limit, too (e.g., the PRINT spooler has two files open when running). Closing inherited handles (standard or otherwise) is freeing them up both towards the program limit (20) and the total limit (FILES). In your case, though, closing only two handles just wasn't enough. Consider that if PROCOMM has 5 non-preset handles opened, it is already occupying 10 handles (5 standard plus 5 more)! Another two (or more) go to the COMMAND.COM that started your PROCOMM, and there isn't that much left. So, the lesson to remember: THE FILES=nnn CONFIGURATION PARAMETER LIMITS ALL FILE HANDLES IN ALL PROGRAMS TOGETHER. If you are frequently calling programs from programs, use a reasonable value for FILES. By the way, raising the FILES limit by one costs you only 48 bytes, so you really can afford it. If in a crunch, sacrifice one BUFFER - that allows you another 10 handles... ------------------------------------------------------------------------ << Perry The Cynic >> ...!tektronix!ogcvax!omepd!inteloa!perry ...!verdix!omepd!inteloa!perry (Peter Kiehtreiber) -or try- perry@inteloa.intel.com