Operating System - Tru64 Unix
1756358 Members
3364 Online
108847 Solutions
New Discussion юеВ

Difference between kill -4 and kill -9 commands?

 
SOLVED
Go to solution
Mike Bray
Advisor

Difference between kill -4 and kill -9 commands?

Anybody know what the kill -4 command is actually doing on an HPUX server when killing a process? I heard it's the same as using a kill -9 which is very harsh. If so it makes no sense HP would have two options doing the same thing. Any help is appreciated. Thank you. Don't want folks using this command if it stands the risk of leaving shared memory segments, message queues, and temp files in place.
4 REPLIES 4
Steven Schweda
Honored Contributor
Solution

Re: Difference between kill -4 and kill -9 commands?

First, you're posting to a Tru64 forum, not
an HP-UX forum, but it probably matters
little in this case.

"kill" sends a signal to the specified
process. 9 is SIGKILL, 4 is SIGILL. (See
signal.h.) What effect that has depends on
how the program running in the process in
question handles the signal in question.
(And several other signal values, are also
possible.)

In general, process termination will close
any open files, and so on. If you're worried
about temporary files and the like, then you
might wish to add a signal handler to the
application and give the application a chance
to clean up after itself before it dies.

Note that some signals (like SIGKILL) can't
easily be caught, so there's normally a limit
on how certain you can be about your clean-up
code getting executed.

Normal folks are not allowed to send signals
to processes to which they have no rights.
If they whack only their own stuff, what do
you care?
Steven Schweda
Honored Contributor

Re: Difference between kill -4 and kill -9 commands?

Note also that you can use the mnemonics
instead of the numbers with "kill", which
requires more keystrokes, but tends to reduce
the mystery. For example, "kill -KILL" is
equivalent to "kill -9".

And, with so many more appropriate signals
available, why would anyone send SIGILL to
an application, anyway?
Mike Bray
Advisor

Re: Difference between kill -4 and kill -9 commands?

Let me post this in the correct forum. Thank you for the reply and I (and our staff) are fully aware of all the options and how it all works. We are all just baffled that HP was unable (at least at the front line) to tell us the difference between a kill -9 and a kill -4.
Unfortunately we support a wide client base who allows root to be handed out to near anyone on there servers. We seem to get dozen calls or so a month from various folks who used the kill command to "take care of an issue" only to leave us to handle the mess. I'm compiling all the kill options and our order of preference for how they should be used. For some reason it seems like many of them are using Kill -4 (told to do so at some point from a supoort rep). From what the HP rep told me, he thinks it's the same as doing a kill -9 which of course is a last resort and not a first option someone should be using.
Thanks for replying and have a good day.
Steven Schweda
Honored Contributor

Re: Difference between kill -4 and kill -9 commands?

It's only a guess, but 4 (SIGILL) might be
selected because it's not 9 (SIGKILL), and
it may also be unlikely to be handled by any
typical application, so it would have about
the same effect as 9. It's not a very good
reason, but someone might have thought that
it was.

Of course, it might also be the result of a
spelling error somewhere along the line.