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 Subject: Re: DJGPP Setup? In-reply-to: X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp AT delorie DOT com Message-id: References: <0KGZ00GQ8UBIYMM0 AT mta4 DOT srv DOT hcvlny DOT cv DOT net> 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 Precedence: bulk > From: "Rod Pemberton" > Date: Tue, 24 Mar 2009 06:50:05 -0400 > > "Ethan Rosenberg" 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.