Re: Environment Variable - Parent Process --- TIA

From: Keith Thompson (kst-u_at_mib.org)
Date: 02/07/05


Date: Mon, 07 Feb 2005 19:24:48 GMT

glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:
>>> Jimmy Cracker wrote:
>>>
>>>> Is it completely impossible in UNIX to push an environment variable to
>>>> the parent shell? I would like to do something like this: [...]
>
> It is possible in unix, but not in C.
>
> See the tset command, and the X11 resize command.

<OT>
Those commands are examples of ways a parent process can set its own
environment variables based in information from a child process. They
do not illustrate propagating an environment variable directly to a
parent process, which is generally not possible in Unix.
</OT>

The only facility C provides is the getenv() function, whose behavior
is almost entirely system-specific. It allows querying a specific
environment variable; there's no portable way either to set a variable
or to get a list of all environment variables. A conforming C
implementation could be perfectly happy on a system on which child
processes can propagate environment variables to their parents, or
even to unrelated processes. The C standard says nothing about
processes at all.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.


Relevant Pages

  • Re: question about setenv
    ... an external command. ... There do exist programs which set environment variables with the help ... Being an external command, ... on a Unix system. ...
    (comp.unix.shell)
  • Re: New "base document" available
    ... There are many ways to skin a cat and compiler ... Unix, I did some quick searching and found the following: ... "The PRINTENV command is used to display environment variable definitions. ... Environment variables are a feature of the shell, ...
    (comp.lang.cobol)
  • Re: Writing a unix command prompt
    ... > I'm writing a command prompt for unix and I've run into some problems: ... > #define EXIT "exit" ...
    (comp.unix.programmer)
  • Re: Writing a unix command prompt
    ... > I'm writing a command prompt for unix and I've run into some problems: ... > #define EXIT "exit" ...
    (comp.unix.programmer)
  • Re: Writing a unix command prompt
    ... > I'm writing a command prompt for unix and I've run into some problems: ... > #define EXIT "exit" ...
    (comp.unix.programmer)