[Speedycgi-users] alarm function does not seem to work
Brought to you by:
samh
|
From: <jim...@lm...> - 2002-03-25 21:23:54
|
Subject: alarm function does not seem to work
<TOP>
Greetings,
I have been successfully using your Speedy CGI module for quite
some time now, Thanks! However, I can not get Perl's "alarm" function to
work (doesn't ever time out and raise exception). Exact same code works fine
under normal CGI. For some strange reason, it seems to work with the "sleep"
function. I have included below a sample program that always times out
with normal CGI, but ALWAYS completese successfully (but should time out)
when using Speedy. Please advise by replying to this email.
Thanks in advance!
Jim Turner
jim...@lm...
============================================================================
#!/applocal/bin/speedy
print "Content-type: text/html\nWindow-target: _parent", "\n\n";
use lib '.';
use CGI ':standard';
eval 'use CGI::SpeedyCGI; 1';
$runtype = 'NORMAL CGI';
++$runcnt;
eval {$sp_query = CGI::SpeedyCGI->new; $runtype = 'SPEEDY' if ($sp_query->i_am_speedy);};
sub setAlarm
{
die "timeout";
}
$SIG{ALRM} = \&setAlarm;
print "<BR>BEFORE time=".scalar(localtime);
alarm(1);
eval
{
for ($i=0;$i<=1999999;$i++) #LONG-RUNNING LOOP!
{
}
};
print "<BR> AFTER time=".scalar(localtime);
print "<BR>PID=$$ cnt=$runcnt= i=$i= runtype=$runtype Error code =$@=\n";
if ($@ =~ /timeout/)
{
print "<BR>--- TIMED OUT!\n";
}
else
{
print "<BR>Success!\n";
}
alarm(0);
============================================================================
.
|