www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2009/03/24/11:41:07

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Tue, 24 Mar 2009 18:40:14 +0200
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: DJGPP Setup?
In-reply-to: <gqadn4$qc1$1@aioe.org>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp AT delorie DOT com
Message-id: <uab7aoowh.fsf@gnu.org>
References: <0KGZ00GQ8UBIYMM0 AT mta4 DOT srv DOT hcvlny DOT cv DOT net> <gqadn4$qc1$1 AT aioe DOT org>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019