Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!maverick.ksu.ksu.edu!matt.ksu.ksu.edu!jwindley From: jwindley@matt.ksu.ksu.edu (Jay Windley) Newsgroups: comp.lang.c Subject: Re: Setting environment from inside a pg. Keywords: C, environment, DOS Message-ID: <1990Nov27.224005.10808@maverick.ksu.ksu.edu> Date: 27 Nov 90 22:40:05 GMT References: <1990Nov27.214032.12794@evax.arl.utexas.edu> Sender: news@maverick.ksu.ksu.edu (The News Guru) Distribution: usa Organization: Kansas State University Lines: 18 Assuming pg means "program" here's an answer: In UNIX the environment is changed with the putenv(3) function. You pass it a pointer to a string of the format = (e.g., "HOME=/usrc/foo"). The caveat here is that the string must be stored in static memory; either a global or a static character array. Note that this only changes the environment of the current process, not its parent. There is no way under UNIX for a process to change the environment of its parent, since the environment it receives upon invocation is merely a copy of its parent's. Children of the process will receive the altered evironment if they are spawned after the change. -- Jay Windley - CIS Dept. - Kansas State University NET: jwindley@matt.ksu.ksu.edu VOICE: (913) 532-5968 FAX: (913) 532-6722 USnail: 323 Seaton Hall, Kansas State Univ., Manhattan, KS 66506 Obligatory quote: "" -- /dev/null