Thanks (and Alexey, and anyone else whose response I haven't seen yet).
The goal is to compute and set a bunch of environment variables for use by
a program that will be launched from an interactive shell. The truly clean
way to do it would be to fix said program so that it computes the
variables itself and doesn't use environment variables as input. Or set it
up to read a .rc file. But this is what I'm stuck with. Oh well.
thanks
Judah
On Mon, 12 Dec 2005, Rich Kulawiec wrote:
On Sun, Dec 11, 2005 at 06:52:32PM -0500, J. Milgram wrote:
Is it possible for a child process to set an environment variable in the
parent process that launched it?
Nope, at least not through any of the standard programmatic interfaces
that the OS provides.
If you want to get Extremely Tricky I suppose you could reach into
the parent process's memory space (via /proc or similar) and scribble
new environment information into it...but this would be risky and
highly non-portable.
If the goal is to pass info from the child process to the parent, it's
probably much simpler/cleaner to just have them talk over a pipe. If
the child and the parent are written in something that makes setting up
a pipe difficult, then the expedient of having the parent read a file written
by child -- which I know is clunky -- might get the job done.