[Haskell-cafe] Why does sleep not work?
Manlio Perillo
manlio_perillo at libero.it
Tue Feb 10 18:05:25 EST 2009
John Ky ha scritto:
> 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."
> sleep 5 -- doesn't sleep at all
> putStrLn "Done."
>
> Anybody know what's happening?
>
Here is a syscal trace, on Linux:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=1332#a1332
The interesting part:
write(1, "Waiting for 5 seconds.\n"..., 23) = 23
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
nanosleep({5, 0}, 0xbf85f5cc) = ? ERESTART_RESTARTBLOCK (To be
restarted)
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
sigreturn() = ? (mask now [])
write(1, "5\n"..., 2) = 2
So, it seems nanosleep get interruped by a signal.
Manlio Perillo
More information about the Haskell-Cafe
mailing list