1) Don&#39;t use System.Posix.Signals<br>It isn&#39;t necessary and makes your code less portable<br><br>2) The POSIX SIGALRM is used/caught by the RTS and that is why you are seeing strange behavior.<br><br>3) Consider using Haskell exceptions from Control.Concurrent (throwTo).<br>
Not sure what you want to do but you can always &quot;myThreadId &gt;&gt;= \tid -&gt; forkIO $ threadDelay someDelayTime &gt;&gt; (throwTo tid someExceptionVal)&quot;<br><br>Thomas<br><br><div class="gmail_quote">On Mon, Jan 25, 2010 at 10:25 PM, Brian Denheyer <span dir="ltr">&lt;<a href="mailto:briand@aracnet.com">briand@aracnet.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I cobbled the following together from bits and pieces I found on<br>
mailing lists.  Seems straightforward, but the code I&#39;ve included<br>
just sits there.<br>
<br>
The awaitSignal seems to be causing a problem, in that if I remove it<br>
(and don&#39;t call forever recursively) then I get my ALARM 5 sec later.<br>
<br>
Otherwise nothing.  The problem is that if I don&#39;t include awaitSignal,<br>
then, of course, forever is called just as fast as the CPU will go :-)<br>
<br>
Brian<br>
<br>
<br>
import System.Posix.Signals<br>
import System.IO<br>
import Control.Concurrent<br>
<br>
alarm =<br>
    do putStrLn &quot;ALARM&quot;<br>
       hFlush stdout<br>
       return ()<br>
<br>
forever =<br>
    do putStrLn &quot;foo&quot;<br>
       scheduleAlarm 5<br>
       awaitSignal Nothing<br>
       yield<br>
       forever<br>
<br>
main =<br>
    do installHandler realTimeAlarm (Catch alarm) Nothing<br>
       forever<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>