Process Termination

Process Termination

After a process has been created, it starts running and performs whatever its job is. However, nothing lasts forever, not even processes. Sooner or later the new process will end, generally due to one of the following conditions:

1. Normal exit (voluntary).
2. Error exit (voluntary).
3. Fatal error (involuntary).
4. Killed by another process (involuntary).

Most processes end because they have done their work. When a compiler has compiled the program given to it, the compiler carries out a system call to tell the operating system that it is finished. This call is exit in UNIX and ExitProcess in Windows. Screen-oriented programs also support voluntary termination. Word processors, Internet browsers and similar programs always have an icon or menu item that the user can click to tell the process to remove any temporary files it has open and then terminate.

The second reason for termination is that the process discovers a serious error. For instance, if a user types the command

                      cc foo.c

to compile the program foo.c and no such file exists, the compiler simply exits. Screen-oriented interactive processes usually do not exit when given bad parameters. Instead they pop up a dialog box and ask the user to try again.

The third reason for termination is an error caused by the process, often due to a program bug. Examples include executing an illegal instruction, referencing nonexistent memory, or dividing by zero. In some systems (e.g., UNIX), a process can tell the operating system that it wishes to handle certain errors itself, in which case the process is signaled (interrupted) instead of terminated when one of the errors takes place.

The fourth reason a process might terminate is that the process performs a system call telling the operating system to kill some other process. In UNIX this call is kill. The equivalent Win32 function is TerminateProcess. In both cases, the killer must have the essential authorization to do in the killee. In some systems, when a process terminates, either voluntarily or otherwise, all processes it created are killed without delay as well. Neither UNIX nor Windows works this way, however.


process, system calls, memory