On Sep 22, 6:53 am, gk.kalipuray...@gmail.com (Gopal Karunakar) wrote: > I used the $SIG{'INT'} = 'IGNORE'; in a sub in my script so that the > script while executing the particular sub will ignore the ctrl-c. And I gave > $SIG{'INT'} = 'DEFAULT'; at the end of the sub to reset the behavior back to > normal.
Presuming your signal setting is the default on entry to the sub, you can just use local to temporarily set the interrupt: sub foo { local $SIG{INT} = 'IGNORE'; ... } The interrupt signal will be ignored for the scope of the sub. When the sub ends, the interrupt setting returns to its prior value. > But when i give the ctrl-c the process seems to be hanging and I > have to kill the process from the prompt. Is there any way to avoid getting > this behavior?? When i give the ctrl-C the script should just ignore it and > continue the process. I am on Sun Solaris box and using Perl version 5.8.7. > Are you sure there's only one exit point from the sub... ? That's a possible scenario which could bypass your $SIG{'INT'} = 'DEFAULT' reset at the end of the sub. (BTW, that's another advantage to using 'local') Show of the code too. You can just pull out some of the relevant lines to give everyone a better view of the crime scene. It's much easier to spot what might be happening. -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/