Sometimes when I'm running a killall
command from Terminal, a co-worker would suggest or edit my scripts to show killall -HUP
.
What does the -HUP
part do?
bashcommand linemacosterminal
Sometimes when I'm running a killall
command from Terminal, a co-worker would suggest or edit my scripts to show killall -HUP
.
What does the -HUP
part do?
Best Answer
The
-HUP
option is the signal that's sent to the processes by thekillall
command. It can be a little hard to tell, but the relevant entry in thekillall
manual is:The difference between the default
TERM
signal thatkillall
sends and theHUP
signal depends largely on the program you're sending the signal to. At the program end, they receive a different interrupt signal value. So the program can catch the interrupts and decide, based on the value, if they should do one thing or the other.The
TERM
signal (historically the "terminate signal") is usually sent to a program to request its termination (which is a politer version of forcing its termination with theKILL
signal). The program is free to catch and ignore theTERM
signal. It doesn't have to terminate if it doesn't want to and it can completely ignore this signal.The
HUP
signal (historically the "hangup signal") is usually sent to a program to request that it restarts and re-reads all its configuration in the process. The actual behaviour of the program depends on the program-specific implementation. Not all programs catchHUP
and they aren't required to by convention or dogma. For example, the Apache web server will catch aHUP
signal and re-read all its configuration files but it won't restart any processes.If you want to truly terminate the processes and not worry about whether they're going to catch and obey the signal uses the
KILL
signal. It cannot be caught or ignored and results in process termination.For a good review of available POSIX signals see this Wikipedia article.