For every call on “exit”, there should be a matching call on “wait” by an anxious parent or ancestor. The principal function of the latter procedure, which implements the “wait” system call, is for the parent or ancestor to find and dispose of a “zombie” child.
“wait” also has a secondary function, to look for children which have “stopped” for tracing (which is the next major topic).
Search the whole “proc” array looking for child processes. (If none exist, take an error exit (line 3317));
If the child is a “zombie”:
save the child’s process identifying number, to report back to the parent;
read the 256 word record back from the disk swap area, and release the swap space;
reinitialise the “proc” array entry;
accumulate the various accounting entries;
save the “u_arg[0]” value also to report back to the parent;
Is the child in a “stopped” state? (If so, wait for the discussion on tracing);
If one or more children were found but none were “zombies” or “stopped”, “sleep” and then look again.