Mail Archives: djgpp/2009/03/24/11:41:07
> From: "Rod Pemberton" <do_not_have AT nohavenot DOT cmm>
> Date: Tue, 24 Mar 2009 06:50:05 -0400
>
> "Ethan Rosenberg" <ethros AT earthlink DOT net> wrote in message
> news:0KGZ00GQ8UBIYMM0 AT mta4 DOT srv DOT hcvlny DOT cv DOT net...
>
> In comp.os.msdos.djgpp,
>
> > I have a program that opens almost 30 files.
>
> How is that possible?... What version of DOS and DJGPP are you using?
>
> According to the following source, DOS limits a single process to a maximum
> of 20 file handles even if config.sys' FILES= line is larger. Three of
> these 20 handles are consumed by stdin, stdout, stderr.
That's correct by default, but then you can call Int 21h/AH=67h to
expand the file handle tables to upto 255 handles. DJGPP library does
precisely that under the hood when you open the 20th file. The
relevant code fragment (from dosio.c:__file_handle_set) is this:
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
if ((size_t)fd >= (count-1) && count < 255)
{
int oldcount = count;
count = 255;
__file_handle_modes = (char *)malloc(count * sizeof(*__file_handle_modes));
memcpy(__file_handle_modes, init_file_handle_modes, sizeof(init_file_handle_modes));
memset(__file_handle_modes + oldcount, 0, (count-oldcount)*sizeof(__file_handle_modes[0]));
/* Tell DOS to allow more */
r.h.ah = 0x67;
r.x.bx = count;
__dpmi_int(0x21, &r);
}
And __file_handle_set is called by _open each time it succeeds, just
before it returns.
> Perhaps, DOS is automatically closing your extra files or DJGPP is reusing
> the file handles... (?)
I don't believe any of this is, or could be, happening.
- Raw text -