Remember the different Linux manual sections.
man 1  ->  user commands
man 2  ->  Linux system calls
man 3  ->  C library functions (but not necessarily C Standard Library functions)
man 4  ->  special files
man 5  ->  file formats
man 8  ->  administration and privileged commands

Note: These are the current manual sections. Our textbook uses an
older numbering for manual sections. For example, the book considers
Section 4 to be file formats, but that is now Section 5.

You can get an introduction to section n with the command
$ man n intro


--------------------------------------------------------------------------
Chapter 8

The example programs from this chapter should be used in the following order.

exec1.c
psh1.c
forkdemo1.c
forkdemo2.c
forkdemo3.c
waitdemo1.c
waitdemo2.c
psh2.c


--------------------------------------------------------------------------
Section 8.2

Here are commands that let you get information about running processes.

man 1 ps
man 1 pstree
man 1 top


--------------------------------------------------------------------------
Section 8.3

man 5 shells

man 1 bash

Here are some Wikipedia pages about shells.
Thompson shell
Unix shell
Shell
Comparison of shells
Command-line interface (CLI)


--------------------------------------------------------------------------
Section 8.4

The main shell loop looks (roughly) like this.

   while ( ! end_of_input )
   {
      get_command();
      execute_command();
      wait_for_command_to_finish();
   }

This is an example of a REPL (Read-Eval-Print Loop)


A REPL is one way to work with an interpreted programming language
(like Python, JavaScript, BeanShell, Matlab, Ruby, Scala, Haskell, Scheme, picoc, Ch, etc).


A real Linux shell, like bash or tsh, is a REPL to a fairly sophisticated
programming language. This is one of the main advantages that a command-line
interface shell (a CLI shell) has over a GUI shell. A GUI shell (usually
implemented as a "desktop interface") is never a programming language.
So a CLI shell may seem "old fashion" but it is, in a fundamental way,
more powerful than any GUI shell (but not easier to use). So CLI shells
will be around forever, though there is much room for improving their
usability.


man 3 execvp

man 2 fork

man 2 wait
man 3 exit


--------------------------------------------------------------------------
Section 8.5


Here is a more detailed outline of the main shell loop (REPL).

   while ( ! end_of_input )
   {
      get_command();         // read a command from the user
      rv = fork();           // create a child to run the command
      if ( 0 == rv )         // child process,
         exec( command );    //     runs the command
      else                   // parent process,
         wait_for_child();   //     waits for child to complete
   }


--------------------------------------------------------------------------
Section 8.6



--------------------------------------------------------------------------
Section 8.7.1

man 3 exit
man 2 _exit


--------------------------------------------------------------------------
Section 8.7.2

The execve() system call

man 2 execve

is used to implement the whole "family" of exec() library functions.

man 3 exec

Notice that these are Linux/Unix library functions,
not C Standard Library functions.

The C Standard Library doe not have a function for creating processes.
C process control

The closest function it has is system().

man 3 system