delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/22/02:27:46

Date: Mon, 22 Sep 1997 09:26:18 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: File-handle inheritance
In-Reply-To: <199709212151.RAA16096@delorie.com>
Message-ID: <Pine.SUN.3.91.970922092526.11436D-100000@is>
MIME-Version: 1.0

On Sun, 21 Sep 1997, DJ Delorie wrote:

> If we're going to do it in the stub, why not only close as many as we
> need?  If we only need two or three, only close the last two or three,
> preserving as many as we can for the applications.

I agree.  We need only one handle (for opening the .exe file), since once
crt0 is called, it will bump the handle table size to 255 as the need
arises.

How about the following change:

diff -c src/stub/stub.a~0 src/stub/stub.asm
*** src/stub/stub.a~0	Mon Sep 22 07:37:06 1997
--- src/stub/stub.asm	Mon Sep 22 07:46:42 1997
***************
*** 243,248 ****
--- 243,258 ----
  ;-----------------------------------------------------------------------------
  ;  Load the COFF information from the file
  
+ ;; When we are spawned from a program which has more than 20 handles in use,
+ ;; all the handles passed to us by DOS are taken (since only the first 20
+ ;; handles are inherited), and opening the .exe file will fail.
+ ;; Therefore, we forcefully close handle 19, to make sure at least one
+ ;; handle is available.
+ 
+ 	mov	ah, 0x3e
+ 	mov	bx, 19
+ 	int	0x21			; don't care about errors
+ 
  	mov	ax, 0x3d00		; open file for reading
  	mov	dx, loadname
  	int	0x21


- Raw text -


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