[email protected]
[Top] [All Lists]

[Haskell-cafe] scheduling an alarm

Subject: [Haskell-cafe] scheduling an alarm
From: Brian Denheyer
Date: Mon, 25 Jan 2010 22:25:36 -0800
I cobbled the following together from bits and pieces I found on
mailing lists.  Seems straightforward, but the code I've included
just sits there.

The awaitSignal seems to be causing a problem, in that if I remove it
(and don't call forever recursively) then I get my ALARM 5 sec later.

Otherwise nothing.  The problem is that if I don't include awaitSignal,
then, of course, forever is called just as fast as the CPU will go :-)


import System.Posix.Signals
import System.IO
import Control.Concurrent

alarm =
    do putStrLn "ALARM"
       hFlush stdout
       return ()

forever =
    do putStrLn "foo"
       scheduleAlarm 5
       awaitSignal Nothing

main =
    do installHandler realTimeAlarm (Catch alarm) Nothing 

Haskell-Cafe mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>