On Wed, 2009-02-11 at 00:05 +0100, Manlio Perillo wrote: > 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.
This works: > import System.Posix > > main = do > putStrLn "Waiting for 5 seconds." > blockSignals $ addSignal sigVTALRM emptySignalSet > sleep 5 > putStrLn "Done." > So (see my earlier email) `sleep` is lying about what interrupts it :) - George
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
