[techtalk] Is there a Kill -8, too?

Samantha Jo Moore sjmoore at TheTahoeGroup.com
Tue Oct 12 16:45:14 EST 1999


OK, quick kill tutorial...

> Simple question (I hope):
> 
> Why is it '-9' exactly? Are there different kill levels or something? What if
> I typed 'Kill -1'? Just curious, and I doubt I would have the know-how to
> find that exact answer in the man pages ;)

Different programs in Linux (or any unix) communicate via differente mechanisms
called IPC (Inter Process Communications).  One of these mechanisms is called
"signals" which is the equivalent to the "interrupt" in the DOS world.  A program
can send another program a signal, and all it is, is like a jolt that says "HEY!".
In addition to the "HEY!" there is a number associated with the signal so the 
signal would say "HEY!  9!".  

On the receiving end (the receiving program), programers usually create what it
is called a "signal handler routine" and it gets associated with a particular
signal number.  This function or subroutine gets automatically called every time 
the program receives a signal with that particular number.

Just as an example, this mechanism is used by programs like inetd or others to
suspend doing whatever they are doing, reread some config file, and then resume
their normal activities.  (i.e. kill -1 <inetd-pid>)

About the signal numbers...  Linux defines a set of standard signal numbers and
their meanings.  You can find these in /usr/include/asm/signal.h.  There are
some signals for which programers can't create signal handlers, and these signals
are called "un-maskable" signals.  SIGKILL (signal 9) is one of these.  When a
program does not have a signal handler for a particular signal and it receives
one, the program automatically dies.

The way to send a signal to a program through the command line is by using the 
kill command.  The command needs the signal number to be sent and the PIDs of
the receiving processes.  Thus the "kill -9 <pid>" command, which will effectively
terminate the execution of the process with PID = <pid>.  If you typed kill -1 <pid>
then you would be sending the SIGHUP (-1) signal.  The program MAY have a signal
handler for this type of signal so it may not die immediately.  The only way to
surely kill a process is to send the SIGKILL (-9) signal which is un-maskable.

Hope this helps.

Samantha

************
techtalk at linuxchix.org   http://www.linuxchix.org




More information about the Techtalk mailing list