[net.unix] setenv from c

tmb@talcott.UUCP (Thomas M. Breuel) (09/22/85)

In article <2936@ncsu.UUCP>, rlj@ncsu.UUCP (Rick Johnson) writes:
> Is it possible to set a csh environment variable within a C program? I know
> about getenv(), but have failed at attempts to set an environment variable
> from a C program. Basically, what I want to do is "source" a new environment
> variable for the current csh process. Any comments or suggestions would be
> appreciated. Thanks.

[I have heard this question before several times, and think that
a posting is therefore warranted. It belongs in net.unix.]

[see also execve(2) and environ(7)]

The environment strings reside in a process' address space,
which makes them inaccessible to any other process. It is therefore
not possible for one process to change the environment variables of
another process except at the time of creation of an immediate child,
when the environment is passed as the third argument to the execve
system call (other varieties of the exec system call (implemented
as library functions) pass the environment data along automatically).

						Thomas.