How the Shell Executes Other Commands (Unix Power Tools, 3rd Edition)
27.2. How the Shell Executes Other Commands
When the shell executes an
external command (Section 1.9), 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 new 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 execs 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. Section 24.2 has more
information.
--TOR and SJC
27. Shell Interpretation27.3. What's a Shell, Anyway?
Copyright © 2003 O'Reilly & Associates. All rights reserved.
Wyszukiwarka
Podobne podstrony:
ch27ch27 (13)CH27 (11)ch27ch27 (9)ch27 (4)DK2192 CH27ch27ch27 (3)ch27 (2)CH27więcej podobnych podstron