I haven't been able to figure out when should i use the kill signals
such as SIGHUP, SIGTERM, SIGQUIT, etc? there is no mention of the
signals in kill man pages. also are there numeric equivalents for
these signals? basically i'd like to know in which situations do i use
the signals... some examples would be helpful.
thanks!!
Ben
What Unix are you running? On my NetBSD machine, the manual
signal(7) lists all signals, their default action and a short
description.
For the signals that you mention, it says:
Name Default Action Description
SIGHUP terminate process terminal line hangup
SIGQUIT create core image quit program
SIGTERM terminate process software termination signal
Take a look in <sys/signal.h> to see what numbers corresponds to
what signals.
--
Andreas Kähäri
--------------------------------------------------------------
Stable, secure, clean, free: www.netbsd.org
They all have numeric equivalents. HUP is 1, QUIT is 2 (as I recall) and TERM is 15.
The default signal sent by the "kill" command is SIGTERM.
Generally:
SIGHUP is sent on terminal or session closure
(historically it stems from a dial in user hanging
up their modem)
several daemons also use is an an indication that they should
reread their configs (since daemons are the class of programs
for which the concept "hangup" is meaningless)
SIGTERM is what you normally send a program to terminate it
it is the default for the kill command
the default action is program termination
SIGQUIT is normally sent to obtain a core dump of a running program
for debugging purposes. It is not normally caught by programs (because that
would interfere with getting a core dump), with the notable exception
of security related programs (such as setuid executables and things
asking for passphrases) because a core dump will leak
security information
The ^\ keystorke normally generates a SIGQUIT for the process group
on the current terminal.
--
Cameron Simpson, DoD#743 c...@zip.com.au http://www.zip.com.au/~cs/
If it ain't broken, keep playing with it.
Andreas Kähäri wrote:
> Take a look in <sys/signal.h> to see what numbers corresponds to
> what signals.
>
kill -l shows a list of names/numbers
regards
robert
If a program makes any special use of particular signals, its documentation
should describe this. Otherwise, if you're just trying to make a process
go away, just use "kill <pid>", as the default signal is usually the right
one; if it's immune to that, the last resort is "kill -9 <pid>" (if that
doesn't get rid of it, it's unkillable -- either it's a zombie that's
already dead and just waiting to be reaped by its parent, or it's hung in
an uninterruptible device wait in the kernel).
--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
There are comon patterns, though. Most programs don't catch signals, so
kill -1 is the first thing to try. Some programs catch 1 and reread their
configuration files. Many programs that catch -1 to reread use -15 to
terminate cleanly, so kill -15 is the second one to try. kill -9 next,
and tracing parent PIDs next. Reboot last in the sequence.
This pattern is common enough that some shutdown scripts use it.
Since signal 15 (SIGTERM) is the default signal that kill sends, this is
pretty close to what I said (I just didn't require him to memorize the
default -- I had to look it up myself to make sure that you were suggesting
the same signal). The suggestion to send signal 1 (SIGHUP) is not a bad
one, though; some interactive programs may try to save their state if they
get this signal, on the assumption that the user was on a dialup that got
hung up; other programs won't have a handler for SIGHUP, so they'll exit
just like they would for SIGTERM.