| Next | Unix Command Internals | 18 |
In fact, the cd 'command' is not a command at all
There is no /bin/cd
cd must always be implemented as a shell built-in command
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 © 2002 M. J. Dominus |