Environment (Variables)


  • Process attribute

  • Inherited from parent to child process during creation

  • An array of C strings of the form var=value


Shell: Environment Variables, And Process Creation

In the shell, for example, you can see the value of the PATH environment variable like …

$ echo $PATH

You set the value of an environment variable

Prepend home to $PATH, and create new variable MY_VARIABLE

In case the variable is not exported, you export it [1],

$ export PATH
$ export MY_VARIABLE

Now the parent process (PID 1034184) has an environment variable PATH with value /home/jfasch/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:

$ echo $$
$ echo $PATH

In that shell, start a new shell. This looks like nothing happened (the prompt is the same at least), but it has a new PID:

$ bash
$ echo $$