In the past, when I have written Perl scripts to use the %SIG array to
capture interrupt signals, I have been able to intercept a <CTRL>-C from
the user and ignore the user's action. I use this feature to disallow
users from exiting the controlled script I have written, unless they use
the way I want them to exit the script.
At the moment, I have been writting a large Perl Menus program and I
would like the same functionality. However, implementing the following
subroutines as I normally do, does not give me the desired result.
#
# ################## S I G I N T #########################
#
sub sigint {
$SIG{"INT"} = "nicetry";
$SIG{"HUP"} = "nicetry";
$SIG{"QUIT"} = "nicetry";
}
#
# ################## N I C E T R Y #########################
#
#
sub nicetry {
print("^G^G");
}
What happens is the routines setup the array properly and infact call the
routine "nicetry", which just beeps twice. But instead of returning to
the place in the code where the <CTRL>-C was entered, the program
actually exits. I believe this has something to do with the fact that
the interrupt was given while displaying a menu using "&menu_display",
which is a routine from the menu.pl library. The interrupt does not even
return to the line after this menu_display call.
I cannot find anywhere in my code where the the subroutine nicetry
returns to. I have tried to use the menu_quit_routine and menu_setexit
routines, but they do not work as well. The next thing I will try is to
actually go into the menu.pl code itself, however this is not what I
would like to do as I don't want to have problems with future versions of
menu.pl.
Any suggestions would be appreciated.
Neil :-)
\\\//
(o o)
------------------ooO-(_)-Ooo-----------------------------------------
Neil Movold Phone : +1 809 296-1800
Special Operations Consultant Fax : +1 809 295-7269
( i.e. the guy who has to
make it all work :-) )
Internet (Bermuda) Limited E-mail : nmovold_at_ibl.bm
P.O. Box HM2445
Hamilton, Bermuda
HM JX
Received on Sun Oct 15 1995 - 23:41:51 NZDT