Fork, exec, zombies and orphans

Follow a shell as it forks a child, replaces the child's program, collects the child's exit status, and finally adopts a child left behind. Processes and threads · Operating systems.

A shell starts a command, keeps running itself, and still learns how the command ended. Follow the calls that make that possible.

What you will learn

  • Read the two return values of fork and say what each process now holds
  • Tell exec, which swaps a program, from fork, which makes a process
  • Say who reaps a zombie and who adopts an orphan

Lesson outline

  1. One call, two processes
  2. A new program in the same process
  3. What a finished child leaves behind
  4. When the parent exits first

15 minutes · 4 scenes · 0 predict checks · 10 quiz questions

The full lesson is available with Premium.