home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 1.10 Internal and External Commands Chapter 1
Introduction
Next: 1.12 What Makes a Shell Script?
 

1.11 How the Shell Executes Other Commands

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.

- TOR


Previous: 1.10 Internal and External Commands UNIX Power Tools Next: 1.12 What Makes a Shell Script?
1.10 Internal and External Commands Book Index 1.12 What Makes a Shell Script?

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System