When the shell executes an external command ( 1.10 ) , what happens?
UNIX programs are executed through a combination of two system calls (low-level requests to the operating system) called fork and exec .
The exec system call tells the kernel to execute another program. However, the kernel replaces the calling program with the new one being called. This doesn't work too well if you want to return to the original program after the second one has done its job.
To get around this problem, programs that want to stick around first copy themselves with the fork system call. Then the copied program exec s the new program, terminating itself in the process.
You don't really need to know this little tidbit about what goes on behind the scenes, but it sure helps to know about fork and exec when reading some UNIX manuals. Article 38.2 has more information.
-