13.3 Terminating Processes
13.3.1 Identifying processes to terminate
The ps -ef command displays a full listing of every process, including the Process ID (PID) and its Parent Process ID (PPID). When trying to terminate a program or release a hung terminal window, it may not be enough to kill the process ID that is associated with the unresponsive application. It may be necessary to kill the Parent of that process and on rare occasions even the Parent of the Parent. It is important to be able to look at a PID and PPID to be able to trace from the child up the hierarchy to the parent processes that spawned them.

To do this, you must first identify the PID of the lowest level unresponsive process. Normally you would try to kill that processes PID. If this does not stop the process, you may need to kill its parent. Killing a parent process will kill all child processes spawned by it. It is also much quicker to kill a parent process rather than killing perhaps several child processes. The Figure shows three processes and the relationships between them. In this example, the first process was started when the user opened a terminal window from CDE, which spawned the user's opening a terminal window for the default Korn shell (ksh). From there the user opened a C Shell with the csh command. Next they ran a program called sleep 500& which suspends execution for 500 seconds. The ampersand (&) tells the shell to run the command in the background and return the shell prompt so the user can continue working.

Note - The sleep command is frequently used in shell scripts to cause the machine to pause for a specified number of seconds before continuing on to the next command. It is used in this example only for purposes of illustration.

The ps -f command in the Figure is used to see only those processes initiated from the current terminal window. The sleep process has a process id of 785 and its parent process is 742, which is the PID of the C shell (csh). If you terminate PID 742, you will also terminate 785. If you terminate the PID of the Korn shell (ksh), which is 689, you will terminate all processes.