Gossamer Forum
Home : General : Perl Programming :

How can I kill CGI process before it times my site out?

Quote Reply
How can I kill CGI process before it times my site out?
The situation is:



I'm getting information off of another server, recombining it, blah blah blah. My issue is that sometimes the site does not respond (his server bites). When this happens--MY script times out and returns nothing to the user.

I'd like to fail the GET after so many seconds have passed.



Thank you.
Quote Reply
Re: [syeago] How can I kill CGI process before it times my site out? In reply to
If you are on unix, see

perldoc -f alarm

Cheers,

Alex
--
Gossamer Threads Inc.
Post deleted by syeago In reply to
Quote Reply
Re: [Alex] How can I kill CGI process before it times my site out? In reply to
  eval {
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm $timeout;
$nread = sysread SOCKET, $buffer, $size;
alarm 0;
};
if ($@) {
die unless $@ eq "alarm\n"; # propagate unexpected errors
# timed out
}
else {
# didn't
}



Found this--it is greek to me. How would one integrate it to fail a call?