delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/14/09:53:11

Date: Mon, 14 May 2001 16:54:03 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Waldemar Schultz <schultz AT ma DOT tum DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: getenv() question
In-Reply-To: <3AFFC9F0.A428D3CB@ma.tum.de>
Message-ID: <Pine.SUN.3.91.1010514165341.27510C-100000@is>
MIME-Version: 1.0
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

On Mon, 14 May 2001, Waldemar Schultz wrote:

> After srarting a DOS session there normally are set some
> environment variables like PATH COMMAND etc.
> now I want to start an application, that is known to set some
> by itself eg. 290 bytes via putenv() or in a batch wrapper.
> What I was thinking of, is to determine the free space in the
> DOS environment before actually launching the application,
> to be able to tell the user he should increase 
> the 'shell= ... /E:xxx' setting in his config.sys in case the
> free space were less than the needed 290 bytes.

Ah, so you are concerned about launching a subordinate command.com or 
some other program?  In that case, you don't need to worry: the way DJGPP 
spawns programs, there's always enough space in the environment block for 
_all_ of the environment variables recorded in the environ[] array, 
including any variables added by the program.  (In fact, each DJGPP 
program adds some variables to environment when its startup code reads 
djgpp.env.)  This works because the `spawn*' family of functions 
allocates enough space in conventional memory to store all the 
environment variables when it gets ready to launch a subsidiary program.
Unless you have more variables than the 16KB transfer buffer can hold, 
you are safe.  (If the transfer buffer is not large enough, `spawn*' 
functions will refuse to run the program.)

In other words, DJGPP programs and all the subprograms they invoke do not 
inherit the fixed size of their parent COMMAND.COM's environment block.

- Raw text -


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