Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alarm for windows?

Status
Not open for further replies.

ferm

Programmer
Joined
May 16, 2006
Messages
7
Location
FR
Hi,

I'm using Perl v5.6.1 built for MSWin32-x86-multi-thread on a win 2000 server computer.

My perl script sometimes stops the execution indefinitely without finishing!
to prevent this behaviour I tried to use alarm to detect when this happens...
but it doesn't work on Windows OS...do you know any way to simulate this function?
(to call a function if a timeout reaches its limit!)

Thank you!
 
Hi,

use warnings;
use strict;

$SIG{ALRM} = sub { die "timeout" };

eval {
alarm(10);
sleep 60;
alarm(0);
};

works on w2k.

Displeaser
 
Hi,

Which version of perl do you use? When I execute this code
(without the eval) I receive the next error:

The Unsupported function alarm function is unimplemented at testAlarm.pl line 6.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top