Using the kill Command to Control Processes

The kill command is a basic UNIX system command. We can communicate with a running process by entering a command into its interface, such as when we type into a text editor. But some processes (usually system processes rather than application processes) run without such an interface, and we need a way to communicate with them, too, so we use a system of signals. The kill system accomplishes that by sending a signal to a process, and we can use it to communicate with any process. The general format of the kill command is as follows:

# kill option PID

A number of signal options can be sent as words or numbers, but most are of interest only to programmers. One of the most common ones you will use is this:

$ sudo kill PID

This tells the process with PID to stop; you supply the actual PID.

is the signal for kill (9 is the number of the sigkill signal); use this combination when the plain kill shown previously does not work:

$ sudo kill -SIGHUP PID

is the signal to "hang up"stopand then clean up all associated processes, too. (Its number is -l.)

As you become proficient at process control and job control, you will learn the utility of a number of kill options. You can find a full list of signal options in the signal man page.

Was this article helpful?

0 0

Post a comment