No such thing as a small change | |
PerlMonks |
Re: Why does threads::join block SIGALRMby oiskuu (Hermit) |
on Jun 07, 2016 at 13:30 UTC ( [id://1165072]=note: print w/replies, xml ) | Need Help?? |
If the worker does not share data with the main program, it is probably best to fork it off as a child process. Threads are expected to behave nice, as they can write shared data, terminate the whole process with an exec, etc. Implementing the blocking/timeout logic in a thread itself should be preferable. In any case, threads i.e. clones share signal dispositions (signal handlers), so extra care should be taken when mixing threads and signals.1 (Don't use alarm.) That said, you can work around the problem by using Thread::Queue and a baby-sitter.
1) Update. Perl will dispatch signals, thus threads can have their separate handlers. But not a mix of 'IGNORE'/'DEFAULT'/code. It also appears that
In Section
Seekers of Perl Wisdom
|
|