| Next | System Programming in Perl | 27 |
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
The child process can change its own copy, but not the parent's
The program's memory is an important example of this:
my $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 | ![]() |
27 |