Next | System Programming in Perl | 22 |
Similarly a command can't set an environment variable in the parent shell
This is true of almost everything in the process structure:
It is copied when the process forks
So the child process can change its own copy, but not the parent's
The program's memory is an important example of this:
$X = "parent\n"; if (fork() == 0) { # I'm the child $X = "child\n"; } print $X;
Prints:
parent child
The child changed its copy of $X, leaving the parent's unaffected
Next | Copyright © 2003 M. J. Dominus |