Notice that Time::Out is only a nice frontend for alarm, ie it uses exactly the code I described earlier.
So it's unreliable.
alarm(2) doesn't interrupt blocking I/O on MSWin32, so 'timeout' won't do that either.
So that's new information, thanks, I only knew about problems coming from using alarm-based functions inside block - like using sleep...
So to conclude - general solution is the one I described initially, it has known deficences - namely problems with reliability ( thus, there are no solutions to my question about "reliable" way to do that ).
On Unix you can expect lost signals, side effects from 'sleep'
and 'alarm' used inside the block.
On MS you can additionally expect haning on blocking I/O (which is what you're usually trying to detect with timeout).
|