previous | start | next

Refinements: 2

The shell can run programs in the foreground or in the background.

foreground: The terminal driver keeps track of which process should get keyboard input and that process is called the foreground process. When the shell creates a child process and waits for that child process to finish executing the command/program, the child process becomes the foreground process.

background: If the shell doesn't wait for the child to finish; the shell can then read and handle another command while the first command is being executed. That is, the shell remains the foreground process.

System calls can get or set which process is the foreground process of the controlling terminal for the calling process:

      tcgetpgrp - get terminal foreground process (group)
      tcsetpgrp - set terminal foreground process (group)
   


previous | start | next