Process termination

Normally, you use the kill command to end a process.

The kill command sends a signal to the designated process. Depending on the type of signal and the nature of the program that is running in the process, the process might end or might keep running. The signals you send are:

Item Description
SIGTERM (signal 15) is a request to the program to terminate. If the program has a signal handler for SIGTERM that does not actually terminate the application, this kill may have no effect. This is the default signal sent by kill.
SIGKILL (signal 9) is a directive to kill the process immediately. This signal cannot be caught or ignored.
It is typically better to issue SIGTERM rather than SIGKILL. If the program has a handler for SIGTERM, it can clean up and terminate in an orderly fashion. Type:
kill -term ProcessID
(The -term could be omitted.) If the process does not respond to the SIGTERM, type:
kill -kill ProcessID
You might notice occasional defunct processes, also called zombies, in your process table. These processes are no longer executing, have no system space allocated, but still retain their PID number. You can recognize a zombie process in the process table because it displays <defunct> in the CMD column. For example:
 UID   PID  PPID   C    STIME    TTY  TIME CMD
                             .
                             .
                             .
 lee 22392 20682   0   Jul 10      -  0:05 xclock
 lee 22536 21188   0   Jul 10  pts/0  0:00 /bin/ksh
 lee 22918 24334   0   Jul 10  pts/1  0:00 /bin/ksh
 lee 23526 22536  22                  0:00 <defunct>
 lee 24334 20682   0   Jul 10      ?  0:00 aixterm
 lee 24700     1   0   Jul 16      ?  0:00 aixterm
root 25394 26792   2   Jul 16  pts/2  0:00 ksh
 lee 26070 24700   0   Jul 16  pts/3  0:00 /bin/ksh
 lee 26792 20082   0   Jul 10  pts/2  0:00 /bin/ksh
root 27024 25394   2 17:10:44  pts/2  0:00 ps -ef
Zombie processes continue to exist in the process table until the parent process dies or the system is shut down and restarted. In the example shown above, the parent process (PPID) is the ksh command. When the Korn shell is exited, the defunct process is removed from the process table.

Sometimes a number of these defunct processes collect in your process table because an application has forked several child processes and has not exited. If this becomes a problem, the simplest solution is to modify the application so its sigaction subroutine ignores the SIGCHLD signal.