Create an Account
username: password:
 
  MemeStreams Logo

MemeStreams Discussion

search


This page contains all of the posts and discussion on MemeStreams referencing the following web page: How to timeout if a call to an external program takes too long. You can find discussions on MemeStreams as you surf the web, even if you aren't a MemeStreams member, using the Threads Bookmarklet.

How to timeout if a call to an external program takes too long
by Lost at 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.


 
 
Powered By Industrial Memetics