WSU logo


College of Engineering & CS
Wright State University
Dayton, Ohio 45435-0001

CEG 333: Introduction to Unix

Prabhaker Mateti

kill


Syntax: kill -[SIGNAL] PID...

Despite its name, ending processes is only one function of the kill command. More generally, it sends signals to processes (i.e., it raises exceptions). Programs can either catch these signals and handle them gracefully, or allow the operating system default to handle them.

The default signal sent by kill is SIGTERM. A different signal can be given before the PIDs, either by number (kill -1) or by name (with or without the "SIG", kill -HUP and kill -SIGHUP both work).

Signals are sent for other events besides the user running kill. Many of the most common signals are never sent directly by users except when testing. Bugs in a program may cause it to terminate with SIGSEGV, and pressing control-c usually sends SIGINT, for example.

WARNING: signal numbers may vary between Unix flavors. The most common signals usually stay the same, but it's a good idea to check kill -l for supported signals. Further, although many systems provide convenience utilities for common tasks, they sometimes have different effects when moving between systems. For example, the same command that kills all processes matching a certain name on Linux will end all running processes on Solaris!

Common Signals:

Number Name Meaning
1 SIGHUP "Hang up", causes programs to quit or reload their configuration.
2 SIGINT "Interrupt", like control-c in Bash
4 SIGILL "Illegal instruction", meaning bad assembly code.
9 SIGKILL Cannot be caught and thus causes any process to terminate immediately.
11 SIGSEGV "Segmentation fault", a memory or pointer error.
15 SIGTERM Terminate the process, with whatever graceful shutdown it provides (the default).
13 SIGPIPE Pipe redirection failure.
(Varies) SIGSTOP Suspends the process, like control-z in Bash. (18 on Linux, 23 on Solaris)
(Varies) SIGCONT Continues a suspended process, like fg in Bash. (18 on Linux, 25 on Solaris)