Mail Archives: djgpp/2001/05/14/09:53:11
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 -