TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Paul Edwards
from: Lynn Nash
date: 1996-10-21 22:50:00
subject: File handles

PE> I have a new theory.  The theory is that the MSC CRT has a fixed
 PE> array of 20 FILE's.  Now instead of doing as I would have

Paul I missed some mail while on holiday so I may be all wet about this.
Is this DOS or OS/2 you are worring over. Your theory about a fixed array
has always been correct for MSC 6. You recompile the startup files to
change it from 20 for DOS and 40 for OS2. You should find the changes for
_NFILE commented out in the source directory. It is supposed to be pretty
common knowledge for long time MSC users. At the time of MSC 6,
Borland 3.0 was around and had a similar requirement to get more than 20
handles. From the MS Knowledge base
********************
INF: C Cannot Bind Programs with Increased File Handles
5.10 6.00 6.00a 6.00ax 7.00 8.00 | 5.10 6.00 6.00a
MS-DOS                           | OS/2
The information in this article applies to:
 - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
 - Microsoft C for OS/2, versions 5.1, 6.0, and 6.0a
 - Microsoft C/C++ for MS-DOS, versions 7.0 and 8.0
----------------------------------------------------------------------
Summary:
Microsoft C defaults to making 20 file handles available to an
application. This is the case for both OS/2 and MS-DOS. This number
can be increased by modifying the startup source code provided with
Optimizing C version 5.1 and linking in the resulting OBJs. This is
documented in the README.DOC for version 5.1 (search for _NFILE_).
This is also documented in the README.DOC file that shipped with
Microsoft C version 6.0.

However, it is not possible to bind a program that is linked to these
modified .OBJs. This is because the protected mode startup makes a
call to DOSSETMAXFH after being modified. This function is not FAPI
(dual mode) and is not bindable.

In Microsoft C/C++ version 7.0, and 8.0 OS/2 targets are not supported
so binding is not possible.
To give a program more than 20 file handles under both OS/2 and
MS-DOS, you must create separate .EXEs for each environment.
More Information:
An attempt to bind a program that is linked with modified startup will
produce the following error:
   LINK : error L2029: Unresolved externals:
   DOSSETMAXFH in file(s):
   BV3.OBJ(bindv3)
The startup files that must be modified to increase the number of
available file handles are CRT0DAT.ASM and _FILE.C.

MS Development Library
C 6.00 README: Multithread (MT) and Dynamic-Link Library (DLL)
6.00   | 6.00
MS-DOS | OS/2
The information in this article applies to:
 - Microsoft C for MS-DOS, versions 6.0
 - Microsoft C for OS/2, version 6.0
Summary:
The following information is taken from the C Version 6.00 README.DOC
file.
Multithread (MT) and Dynamic-Link Library (DLL) Libraries
---------------------------------------------------------
By default, the C 6.00 MT and DLL libraries support 40 file handles
and streams instead of 20, which is the single thread library default.

To increase the number of file handles (low-level I/O), simply issue a
DOSSETMAXFH call from within your program. This increases the open
file limit for the calling process.

To increase the allowable number of open streams, first make sure that
the number of file handles is greater than or equal to the number of
streams you want. Then rebuild module _FILE.C with the desired _NFILE
setting (as described under the single thread description). Since the
MT and DLL libraries are large model, be sure to compile _FILE.C with
the /AL switch.
*********************

The problem is that the original README.DOC gets overwritten by any
patch file with a new README.DOC. So unless you install an unpatched
version of MSC 6.0 you would probably never see this information.  Since
there were a couple of different patches for MSC 6, "It ain't thar" when
you need to findly read it. Those DOS menu programs used to launch apps
were notorious for eating up file handles; so was any application the
allowed a shell to dos command and then the user executed a new copy of
the program while in a secondary or greater command processor. The DOS
app just inherits the parent process environment when executed so you
might not get your full 17 free handles. MS does have recompiled libaries
with various file handle sizes up to 100 available for download on their
website if you don't want to hassle with two additional object files.

--Lynn

 * SLMR 2.1a * If I've cleared anything up, I'm terribly sorry about it.

--- DB 1.39/004485
* Origin: The Diamond Bar BBS, San Dimas CA, 909-599-2088 (1:218/1001)
SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1
@PATH: 218/1001 3615/50 396/1 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.