Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: "killing" perl5.8-threadsby strider corinth (Friar) |
on Nov 13, 2002 at 21:05 UTC ( [id://212696]=note: print w/replies, xml ) | Need Help?? |
Here's one way to do it:
I'll admit that this isn't the most threads-specific way to do it: it could also be implemented without threads. But it will allow you to do other things while data is being gathered, so I think it should work for you. If IO::Handle uses alarm, and I don't think it does, this will fail on Windows anyway. I have another idea that's slightly more thread-dependent, but I don't have time to think it through or test it. You could send a signal to the thread after five seconds, and then join() it. The thread would have a local $SIG{SOMETHING} to catch the signal you throw at it, and exit without finishing whatever it's doing. How to send a signal to a thread, though, is doubtless an OS-dependent thing. If it has a separate PID and you can find it, great. If not, you may need to send a harmless (or intentionally ignored) signal to the main process. And it may just be impossible. ;) -- Love justice; desire mercy.
In Section
Seekers of Perl Wisdom
|
|