- Normal exit (voluntary): A process terminates when it finishes executing its final statement and asks the OS to delete it by using the system call. At that point, the process may return a status value (typically an integer) to its parent process (via the system call). All the resources of the process -including physical and virtual memory, open files, and I/O buffers- are deallocated by the OS.
- Abnormal termination: programming errors, run time errors, I/O, user intervention.
- Error exit (voluntary): An error caused by the process, often due to a program bug (executing an illegal instruction, referencing non-existent memory, or dividing by zero). In some systems (e.g. UNIX), a process can tell the OS that it wishes to handle certain errors itself, in which case the process is signaled (interrupted) instead of terminated when one of the errors occurs.
- Fatal error (involuntary): i.e.; no such file exists during the compilation.
- Killed by another process (involuntary): A process can cause the termination of another process via an appropriate system call (for example,
in Win32). Usually, such a system call can be invoked only by the parent of the process that is to be terminated.
- A parent may terminate the execution of one of its children for a variety of reasons, such as these:
- The child has exceeded its usage of some of the resources that it has been allocated. (To determine whether this has occurred, the parent must have a mechanism to inspect the state of its children.)
- The task assigned to the child is no longer required.
- The parent is exiting, and the OS does not allow a child to continue if its parent terminates (cascading termination).
- To illustrate process execution and termination, consider that, in UNIX, we can terminate a process by using the system call; its parent process may wait for the termination of a child process by using the system call.
- The system call returns the process identifier of a terminated child so that the parent can tell which of its possibly many children has terminated.
- If the parent terminates, then the child will become a zombie process and may be listed as such in the process status list!. This is not always true since all its children could have been assigned as their new parent the init process. Thus, the children still have a parent to collect their status and execution statistics.
Cem Ozdogan
2011-02-14