This procedure is called when a process is to terminate itself.
Reset the “tracing” flag;
Set all of the values in the array “u.u_signal” (including “u.u_signal[SIGKILL]”) to one so that no future execution of “issig” will ever be followed by execution of “psig”;
Call “close” (6643) to close all the files which the process has open. (For the most part, “closing” simply involves decrementing a reference count.);
Reduce the reference count for the current directory;
Sever the process’s connection with any text segment;
A place is needed to store “per process” information until the parent process can look at it. A block (256 words) in the swap area of the disk is a convenient place;
Find a suitable buffer (256 words) and ...
Copy the lower half of the “u” structure into the buffer area;
Write the buffer into the swap area;
Enter the core space occupied by the process into the free list. (This space is of course still in use, but the use will terminate before any other process gets to dip into the free list again. This could not be done any sooner, because, as will be seen later, both “getblk” and “bwrite” can call “sleep”, during which all sorts of things might happen. In view of all this, it might be reasonable if the statement
were inserted after line 3226.);
Set the process state to “zombie” (i.e. “a corpse said to be revived by witchcraft”
(O.E.D.));
The remaining code searches the “proc” array to find the parent process and to wake it up, to make any children “wards of the state”, and, if they have “stopped” for tracing, to release them. Finally the code includes (for this process) a last call on “swtch”.
Before going on to consider tracing, there are two routines which are closely associated with “exit”, which can be conveniently disposed of now.