Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: Sticky IBM C programming problems (summary of replies) Message-ID: <1990Mar2.131501.23297@virtech.uucp> Date: 2 Mar 90 13:15:01 GMT References: <90055.142524CMH117@psuvm.psu.edu> <9003012109.AA07700@ei.ecn.purdue.edu> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Followup-To: comp.sys.ibm.pc Organization: Virtual Technologies Inc., Sterling VA Lines: 26 In article <9003012109.AA07700@ei.ecn.purdue.edu> tlmfe@EE.ECN.PURDUE.EDU (Mark B Strong) writes: > >Quick question: Why won't an environmental variable I change within >a C program stay after the program is terminated? Setenv() doesn't seem >to work? First of all, this isn't a C questions it is an OS question so I have forwarded followups to comp.sys.ibm.pc The answer is that a programs environmental variables are stored in that program's data space is are lost when the program exits. The only thing special about environment variables is that there exists a convention for passing that portion of your data space to all child processes, but you cannot use it to change the data space of a parent process (which is what you are apparently trying to do). Of course, your program could pass the environment variable changes back through a file descriptor (say stdout) and the parent program could make these changes in it's environment. But you will have to modify both programs to do this. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+