[Chapter 6] 6.2 Parent-Child Relationships
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-10-23T15:37:56Z

#

| Chapter 6 Shell and Environment Variables |

## 6.2 Parent-Child Relationships

No, this is not about the pop psychology of computing. It's just a quick reminder of one important point.

In the environment variable overview (6.1) we said that each process gets its own copy of its parent's environment variables. We chose those words carefully, and if you think about them, you won't make one common mistake.

Sooner or later, almost everyone writes a shell script that gathers some information, sets a few environment variables, and quits. The writer then wonders why there's no trace of the "new" environment variables to be found. The problem is simple. A UNIX process (38.3) cannot change its parent's environment; a UNIX process gets its own copy of the parent's environment, and any changes it makes it keeps to itself. A process can make changes and pass them to its children, but there's no way of going in reverse.

(You can't teach an old dog new tricks.)

- ML

6.1 What Environment Variables Are Good For |  | 6.3 Predefined Environment Variables