perlquestion
remiah
Hello PerlMonk.<br>
<br>
I have console perl program that connects to database, checking records every 30 seconds, and if data has changed it should do it's job. With ctrl + c, I want this program to disconnect from database, so I tried SIGINT signal handler even though Chapter 4 of "Advanced Perl Programming" warned me the trouble of Win32 signal. My program shows no response to ctrl + c while sleeping 30 seconds and this is my problem.
<br><br>
So far, I have read through previous threads,
<a href="http://www.perlmonks.org/?node_id=920500">
SOLVED Perl SIG INT handling conundrum.
</a>
,
<a href="http://www.perlmonks.org/?node_id=307024">
GOTO, Signals and Win32
</a>
, and especially this one
<a href="http://www.perlmonks.org/?node_id=552515">
win32, ctrl-c, sleep, and signals
</a>.
<br>
"set PERL_SIGNALS=unsafe" gives me quick response but it yields fatal error dialog saying perl has crashed. I am using perl 5.12.1 of Win32 IndigoAMPP package. Below is my sample code.
<code>
use strict;
use warnings;
#this doesn't work
#$ENV{PERL_SIGNALS} = "unsafe";
local $SIG{INT} =sub {
print "in SIGINT ...exitting\n";
#here I want disconnect from database;
exit;
};
while (1){
print "in while loop\n";
sleep 30;
#this is what I can do best so far...
#sleep 3 for (0 .. 10);
}
</code>
I am glad with any advice.<br>