[Haskell-cafe] Why does sleep not work?

John Ky newhoggy at gmail.com
Mon Feb 9 18:39:03 EST 2009


Hi Peter,

Source code:
import System.IO
import System.Posix

main = do
      putStrLn "Waiting for 5 seconds."
      sleep 5 -- doesn't sleep at all
      putStrLn "Done."

OS:
Mac OS X 10.5

Compile command:
ghc --threaded testsleep.hs

If I remove --threaded, then it does sleep.

Thanks,

-John

On Tue, Feb 10, 2009 at 8:59 AM, Peter Verswyvelen <bugfact at gmail.com>wrote:

> Hi John,
> Which sleep are you using? From which module? Can you show the full source
> with import statements?
>
> Cheers,
> Peter
>
> 2009/2/9 John Ky <newhoggy at gmail.com>
>
>> Hi Haskell Cafe,
>>
>> I wrote very short program to sleep for 5 seconds compiled with the
>> -threaded option in ghc on the Mac OS X 1.5.
>>
>> I am finding that using the sleep function doesn't sleep at all, whereas
>> using threadDelay does:
>>
>> main = do
>>       putStrLn "Waiting for 5 seconds."
>>       threadDelay 5000000 -- works
>>       putStrLn "Done."
>>
>> main = do
>>       putStrLn "Waiting for 5 seconds."
>>       sleep 5 -- doesn't sleep at all
>>       putStrLn "Done."
>>
>> Anybody know what's happening?
>>
>> Thanks
>>
>> -John
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090210/2098a581/attachment.htm


More information about the Haskell-Cafe mailing list