To: Bill Davidson Cc: Long Doan , djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: putenv() and system() Date: Tue, 07 Feb 95 11:09:25 +0200 From: "Eli Zaretskii" > what I was getting at. I have always thought that this was a peculiarity > of DOS, which doesn't like you messing with the master environment block > (yes, I know it can be done, but I also know how difficult it is). I I know that much. I didn't want for system() to change the master environment, though. As system() is usually implemented by calling a subsidiary shell which is then passed the command line you specify as the argument to system(), is it too much to expect that the child of that subsidiary shell inherits all the environment variables of the parent, i.e. the program which called system() in the first place? > Getting back to your original post, could you try something like: > system("set var_to_change=new value"); > system("do_something"); No, this won't work, and I don't expect it to. It won't work under Unix, either, because the first system() only affects the environment of the shell born to execute that ``set'' command, and that environment dies right after ``set'' is executed. The next system() invokes a new instance of the shell, which doesn't know about the new value of var_to_change.