Operating System - HP-UX
1833875 Members
1632 Online
110063 Solutions
New Discussion

Re: Questions about Kill -HUP

 
SOLVED
Go to solution
Jared Westgate_1
Valued Contributor

Questions about Kill -HUP

Hello,

I was hoping that someone could clear up a few things for me. I've written a security script that will allow certain users only 1 concurrent login. I can already forsee problems with users being logged on somewhere else and not knowing it. My question is this: If I have to kill these existing sessions (just posix shells), will a kill -HUP gracefully exit any child processes that may be running. I know the shell won't respond to a kill -15, and I don't want to use a kill -9. What exectly does a kill -HUP do (as opposed to a kill -15)? Is there a more correct way of terminating users? Thank you for all your help.

Jared
4 REPLIES 4
Alan Riggs
Honored Contributor

Re: Questions about Kill -HUP

kill -1 will generally terminate child processes, but you might want to issue an explicit kill -18 (SIGCHLD) first.
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Questions about Kill -HUP

Hi Jared,

Without try to sound too smug, a kill -HUP does what ever it's told to do. Specifically,
if a process has a signal handler (or in the case of the shell a trap statement) it takes
whatever action that is coded upon receipt of the particular signal.
You could have one response to a SIGHUP and another to a SIGTERM (15). You can also instruct the process (or shell) to ignore certain signals. You should man sh and carefully examine the trap section.

One thing you should also be aware of is that you are not guarenteed to be sent a hangup signal. For example, if using a serial terminal or modem, if it's not properly wired and configured then the system has no idea that the user has turned off the device.

Hope this gets you started, Clay
If it ain't broke, I can fix that.
Alan Riggs
Honored Contributor

Re: Questions about Kill -HUP

Clay's points are well made. As a rule, I tend to "escalate" kills until the offending process goes away. Start gentle(18, 15), then be firm(1,2,6) then drop the hammer(9).

This gives every opportunity for a clean departure, but ensures that any process responding to signals will, in fact, go away.
Jared Westgate_1
Valued Contributor

Re: Questions about Kill -HUP

Thanks for all the replies! It looks like I'm missing some of the basics here. Apparently, when you send a kill to a process, the process knows how to handle to signal by means of trap statements? That would explain a lot.

I assume by the name, a kill -18 is intended to stop the child processes (if there is a trap setup for it).

Are there any signals (besides 9) that don't require traps defined?

Thanks again for all your help!