Results 1 to 4 of 4
I am a beginner in scripting and following is written on the top of my script
trap "" HUP
Can an one help me in understanding this?
Thanks...
- 01-09-2008 #1Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
meaning of trap "" HUP
I am a beginner in scripting and following is written on the top of my script
trap "" HUP
Can an one help me in understanding this?
Thanks
- 01-09-2008 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- UK
- Posts
- 211
trap is a builtin command used for specifying the actions to take on receipt of signals.
so:
trap HUP means Hang up; usually sent when a terminal goes off line, or a user logs out.
Hope this helps.
- 01-09-2008 #3
This means "In this script, ignore the hangup signal."
For an introduction to signals, and a list of signals, see this.
You could also have spelled this as
bash scripts normally stop running and emit "Hangup" to the screen and stop running when they receive a hangup signal. The statement you asked about causes this signal to be ignored. You can put something between the quotes if you wish; that will be a bash statement to execute upon receiving the hangup signal. It can be as simple as printing the content of some variables, or it can be the invocation of some other script, or it can be almost anything.Code:trap "" SIGHUP
In addition to signals, you can also say things like
to run some command upon exit from your script.Code:trap "somethingsomething" EXIT
Hope this helps.--
Bill
Old age and treachery will overcome youth and skill.
- 01-10-2008 #4Linux Newbie
- Join Date
- Jan 2008
- Posts
- 114
Thanks, now understood


Reply With Quote