COM310 / Processes

exit() and wait()

See it on a timeline

When the parent is already waiting, like our program Parent Child fork(), then wait() wait() returns 7 exit(7), a zombie for an instant When the parent is busy and calls wait() later Parent Child fork() exit(7) wait() returns 7 zombie: finished, but not collected yet running waiting zombie

A finished child stays a zombie until its parent collects it with wait(). In our program the parent is already waiting, so that only takes an instant.

Trace the code

Screen output

You can also use the arrow keys or the space bar.
C code: exit_wait.c