Previous Table of Contents Next

Killing Processes

Sometimes you need to eliminate a process entirely. Use the kill command to do this. The syntax of the kill command is kill -signal PID, where signal is a number or a name.

CAUTION! Kill a process only if you cannot get it to quit in the usual way.

Sometimes processes do not die when you use the kill command. The three most common cases are:

  The process is waiting for a device, such as a tape drive, to complete an operation before exiting.
  The process is waiting for resources that are unavailable because of NFS problems. To kill such a process, type kill -QUIT PID.
  The process is a zombie, as shown by the message defunct in the ps report. A zombie process is one that has had all its resources freed, but has not received an acknowledgment from a parent process, receipt of which would ordinarily remove its entry from the process table. The next time a system is booted, zombie processes are cleared. Zombies do not affect system performance, and you do not need to remove them.

To kill a process:

1.  Become superuser. You must be superuser to kill a process that you do not own.
2.  Type ps -e and press Return. A list of the processes is displayed. Use the PID ( process ID) number in the first column as input to the next step. If you know which process is causing the problem, you can type ps -e | grep process-name and press Return to focus your search.
3.  Type kill PID and press Return. When you type kill with no arguments, signal 15 is sent.
4.  Type ps -e and press Return. Check to see if the process has terminated. If it's still there, go to step 5.
5.  Type kill -9 PID and press Return. The process should be terminated. Type man -s5 signal and press Return to see a description of the signals used by kill.

For example, if OpenWindows is frozen on the system oak, you must log in remotely and kill the process from another system:

elm% rlogin oak
oak% ps -e | grep openwin
2212 pts/Ø   Ø:ØØ openwin
2213 pts/1    Ø:ØØ grep openwin
oak% su
oak# kill 2212
oak# exit
oak% logout

Using the /usr/proc/bin Commands

The Solaris 2.6 release provides you with a set of commands that you can use to display detailed, technical information about active processes. These commands are summarized in Table 1-6.

Table 1-6 Process Tools in the /usr/proc/bin Directory

Command Description
pstop pid Stop the process.
prun pid Restart the process.
ptime pid Time the process using microstate accounting.
pwait pid Wait for specified processes to terminate.
pcred pid*Display credentials.
pfiles pid*Display fstat and fcntl information for open files.
pflags pid*Show /proc tracing flags, pending and held signals, and other status information for each lwp.
pldd pid*Show dynamic libraries linked into each process.
pmap pid*Show address map space.
psig pid*Display signal actions.
pstack pid*Display hex+symbolic stack trace for each lwp.
ptree pid Show process trees containing specified PIDs.
pwdx pid*Display current working directory.

*Must be superuser to execute.

NOTE:  If you use the /usr/proc/bin commands frequently, add the process tool directory to your PATH variable to make the commands more easily accessible.

All of the /usr/bin/proc commands use the process ID (PID) as the argument to the command. You can obtain the PID by using the ps -e and the grep commands to search for the name of the process you want more information about. The following example displays the PID for the openwin process in the first column:

oak% ps -e | grep openwin
2212 pts/Ø   Ø:ØØ openwin
2213 pts/1    Ø:ØØ grep openwin

Previous Table of Contents Next