Setting environment from inside a pg.
Jay Windley
jwindley at matt.ksu.ksu.edu
Wed Nov 28 09:40:05 AEST 1990
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 <var>=<value> (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 at 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
More information about the Comp.lang.c
mailing list