Operating System - HP-UX
1829863 Members
2233 Online
109993 Solutions
New Discussion

Re: how to remove trap ( unset )

 
SOLVED
Go to solution
blu.karthi
Advisor

how to remove trap ( unset )

how unset the trap
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor

Re: how to remove trap ( unset )

Hi:

If you mean a shell 'trap' then:

...
trap 'echo sorry' INT
...
trap '' INT

Regards!

...JRF...
blu.karthi
Advisor

Re: how to remove trap ( unset )

hi, thank for the response... my requriment is to remove all trap..... there should not be any trap...
James R. Ferguson
Acclaimed Contributor

Re: how to remove trap ( unset )

Hi (again):

> my requriment is to remove all trap..... there should not be any trap...

Again, I assume that this whole discussion relates to the shell. Thus if you had set a 'trap' for (example) SIGHUP, SIGINT, SIGQUIT and SIGTERM you could reset (restore) their default action by doing:

# trap '' HUP INT QUIT TERM

You can see what's set in your script, you can do:

# trap

...which will simply print the handler associated with each set trap.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor
Solution

Re: how to remove trap ( unset )

Hi (again):

I'm sorry, I think I understand what you mean by "unset".

To restore a trap (signal) to it's original (DEFAULT) value do:

# trap - INT

If, however, you do:

# trap '' INT

...this is equivalent to an IGNORE action.

This script snippet will help you see the various actions:

#!/usr/bin/sh
trap 'echo sorry' INT QUIT HUP KILL
trap
echo "I'm safe"
read REPLY
trap - INT
trap - QUIT
echo "I'm no longer immune"
read REPLY
trap
exit

...run the above and attempt a CTL_C to break the script after the first and then after the second read().

Regards!

...JRF...
blu.karthi
Advisor

Re: how to remove trap ( unset )

thanks.....