Create an Account
username: password:
 
  MemeStreams Logo

How to timeout if a call to an external program takes too long

search

Lost
Picture of Lost
My Blog
My Profile
My Audience
My Sources
Send Me a Message

sponsored links

Lost's topics
Arts
Business
Games
Health and Wellness
Home and Garden
Miscellaneous
Current Events
Recreation
Local Information
Science
Society
Sports
Technology

support us

Get MemeStreams Stuff!


 
How to timeout if a call to an external program takes too long
Topic: Technology 4:57 am EDT, Oct  3, 2007

Can we see the non-working code that uses alarm? This is a textbook example of when to use alarm.

Here, the alarm is triggered, and then processing continues:

alarm 5;
$SIG{ALRM} = sub { print "alarm!\n" };
my $yawn = `sleep 10 ; echo "yawn"`;
print "yawn? $yawn\n";
__END__
alarm!
yawn? yawn

Sometimes when I execute programs from perl using system() they don't return and perl gets stuck. This fixes that.

How to timeout if a call to an external program takes too long



 
 
Powered By Industrial Memetics
RSS2.0