Front page | perl.ithreads |
Postings from September 2011
threads and alarm
Thread Next
From:
alfonso caponi
Date:
September 1, 2011 03:08
Subject:
threads and alarm
Message ID:
CAF3e4iYCBdr-5+Z9LsAPyrQ=q6MXU94ujZH5U+jhTnrTHcrX=A@mail.gmail.com
#!/usr/bin/perl
use strict;
use warnings;
use threads;
$|=1;
$SIG{INT} = sub {
threads->exit();
exit(1);
};
my $thr = threads->new(\&Testsub);
$thr->detach();
while(1){
}
exit(0);
sub Testsub{
while(1){
eval {
local $SIG{ALRM} = sub { print "alarm!\n"; };
alarm(2);
sleep 5;
alarm(0);
};
}
}
Thread Next
-
threads and alarm
by alfonso caponi