The ->kill() method for threads was added in threads v1.27 (back in May 2006). If you update the threads module, you'll have this capability. The 'best' way to do this is to install Bundle::Thread from CPAN.
On Thu, Sep 1, 2011 at 13:27, Danny Wong (dannwong) <dannw...@cisco.com> wrote: > How can you do this using perl 5.8.8? > > -----Original Message----- > From: jdhed...@gmail.com [mailto:jdhed...@gmail.com] On Behalf Of Jerry D. > Hedden > Sent: Thursday, September 01, 2011 5:48 AM > To: alfonso caponi > Cc: perl-ithreads@perl.org > Subject: Re: threads and alarm > > Signals are received by thread 0 - the main thread. Therefore, when a > thread sets an alarm, the ALRM signal hits the main thread not the > thread that set the alarm. I don't know your particular needs, but if > you want the thread to get the alarm, then you need to set the alarm > handler in the main thread, and then send the ALRM signal to the > thread using $thr->kill('ALRM'). Thus, in your example, if you add > the following: > > $thr->detach(); > $SIG{ALRM} = sub { $thr->kill('ALRM') }; > > It'll work. > > On Thu, Sep 1, 2011 at 06:08, alfonso caponi <alfonso.cap...@gmail.com> wrote: >> Hi list, >> >> I need help! :) How can I use "alarm" without exit from a thread only >> (without making the script end!). >> >> For example this works (without threads): >> >> while(1){ >> eval { >> local $SIG{ALRM} = sub { print "alarm!\n"; }; >> alarm(2); >> print "hi\n"; >> sleep 5; >> alarm(0); >> }; >> } >> >> but the script in attachment doesn't works :( >> >> Thank you very much, >> Al >> >