develooper Front page | perl.perl5.porters | Postings from July 2005

Re: [perl #16807] getting alarm() to work within threads

From:
Elizabeth Mattijsen
Date:
July 14, 2005 02:25
Subject:
Re: [perl #16807] getting alarm() to work within threads
Message ID:
p062102c0befbdfb0e5dd@[192.168.56.3]
At 1:38 AM -0700 7/14/05, Michael G Schwern via RT wrote:
>  > [elizabeth - Wed Aug 28 02:01:38 2002]:
>>
>>  This shows it all:
>>
>>  == alarm ========================================================
>>  use threads;
>>  $SIG{ALRM} = 'a' if @ARGV; # must assign outside of threads
>>  threads->new( sub {
>>     $SIG{ALRM} = sub { die "alarm went off properly\n" };
>>     eval {
>>       alarm( 3 );
>>       1 while 1;
>>       alarm( 0 );
>>     };
>>     warn "\$\@ = $@";
>>  } )->join;
>>  =================================================================
>>
>>    $ perl alarm 1
>>    $@ = alarm went off properly
>>
>>    $ perl alarm
>>    Alarm clock
>
>0 ~$ bleadperl ~/tmp/test 
>Alarm clock
>0 ~$ bleadperl ~/tmp/test 1
>...hang...
>
>Is that an improvement? :)  That's bleadperl@25129 on OS X 10.3.9

To be quite honest, I've given up on threads in Perl 5.

Signals and threads in Perl are the Wild West, really, last time I checked....



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About