|HP-UX Reference > K
HP-UX 11i Version 3: February 2007
kill — send a signal to a process; terminate a process
The kill command sends a signal to each process specified by a pid process identifier. The default signal is SIGTERM, which normally terminates processes that do not trap or ignore the signal.
kill recognizes the following options:
pid is a process identifier, an unsigned or negative integer that can be one of the following:
Process numbers can be found with the ps command (see ps(1)) and with the built-in jobs command available in some shells.
Signal Names and Numbers
The following table describes a few of the more common signals that can be useful from a terminal. For a complete list and a full description, see the header file <signal.h> and the manual entry signal(5).
SIGNULL (0), the null signal, invokes error checking but no signal is actually sent. This can be used to test the validity or existence of pid.
SIGTERM (15), the (default) terminate signal, can be trapped by the receiving process, allowing the receiver to execute an orderly shutdown or to ignore the signal entirely. For orderly operations, this is the preferred choice.
SIGKILL (9), the kill signal, forces a process to terminate immediately. Since SIGKILL cannot be trapped or ignored, it is useful for terminating a process that does not respond to SIGTERM.
The receiving process must belong to the user of the sending process, unless the user has appropriate privileges.
As a single special case, the continue signal SIGCONT can be sent to any process that is a member of the same session as the sending process.
Upon completion, kill returns with one of the following values:
signals process number 6135 to terminate. This gives the process an opportunity to exit gracefully (removing temporary files, etc.).
The following equivalent commands:
kill -s SIGKILL 6135 kill -s KILL 6135 kill -s 9 6135 kill -SIGKILL 6135 kill -KILL 6135 kill -9 6135
terminate process number 6135 abruptly by sending a SIGKILL signal to the process. This tells the kernel to remove the process immediately.
If a process hangs during some operation (such as I/O) so that it is never scheduled, it cannot die until it is allowed to run. Thus, such a process may never go away after the kill. Similarly, defunct processes (see ps(1)) may have already finished executing, but remain on the system until their parent reaps them (see wait(2)). Using kill to send signals to them has no effect.
Some non-HP-UX implementations provide kill only as a shell built-in command.
This manual entry describes the external command /usr/bin/kill and the built-in kill command of the POSIX shell (see sh-posix(1)). Other shells, such as C and Korn (see csh(1) and ksh(1) respectively), also provide kill as a built-in command. The syntax for and output from these built-ins may be different.