Date: Mon, 6 Feb 1995 21:44:50 -0500 (EST) From: Long Doan To: Eli Zaretskii Cc: Bill Davidson , djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: putenv() and system() On Mon, 6 Feb 1995, Eli Zaretskii wrote: > > the COPY. When you call system() the shell gets its own copy of > > the (unmodified) master environment, because it gets from the same source > > your program did. So the flow is OS-->yourprog-->OS-->system(). > > No, it's OS-->myprog-->COMMAND.COM which is child of myprog-->child, > so it should work (as it does with other compilers). > > The problem is, as far as I could see, that putenv() only > puts the variable into an environment block which is then > used by the spawnXXX() family, while system() is implemented > in the current version of the library by directly calling > go32 exception handler which is only passed the string you > give to system(). Thus, system() never sees the additional > environment variables you set with putenv(). Upon startup, GO32 recieved a copy of the environment from DOS, it then copied this environment to the program stack (it can be found at esp+8). (This only apply to the program being run, not the debugger, in V1.1x.) When the program calls putenv (), it only modifies its own copy of the environment, which will be coppied to the child process's stack. But when system () is called, command.com looks at DOS's copy of the environment, which doesn't have the modification. +--------------------------------------------------------+ | Long Doan ldoan1 AT osf1 DOT gmu DOT edu | | ld AT netrix DOT com | +--------------------------------------------------------+