SPUG: Need an asynchronous alarm handler
ced at carios2.ca.boeing.com
ced at carios2.ca.boeing.com
Fri May 25 13:43:53 CDT 2001
> alarm $timeout;
> $foo = eval {
> local $SIG{ALRM} = sub { die "TIMEOUT" };
> $socket->accept()
alarm 0; # move alarm call to here
> }
> # alarm 0; # move alarm call from here
> if ($@ =~ /TIMEOUT/) {
> print "Timed out\n"
> }
> while ($foo->getline) {
> # do some stuff
> }
Very minor nit but alarm(0) should actually be moved
inside the eval. Otherwise, there's a small window for
the alarm to go off early as someone pointed out on
clpm.
Rgds,
--
Charles DeRykus
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list