[Haskell-cafe] Why does sleep not work?

George Pollard porges at porg.es
Tue Feb 10 18:22:04 EST 2009


On Tue, 2009-02-10 at 09:57 -0800, Corey O'Connor wrote:
> The POSIX sleep function is defined as:
>     sleep() makes the current process sleep until seconds seconds have
> elapsed or a signal arrives which is not ignored.
> 
> Sounds like a signal is arriving that is interrupting the sleep.
> 
> -Corey O'Connor

I tested this when testing the original code; sleep reports that the
signal received is 5 (SIGTRAP). However, the following code does not
work:


> import System.Posix
> 
> main = do
> 	putStrLn "Waiting for 5 seconds."
> 	print sigTRAP
> 	blockSignals $ addSignal sigTRAP emptySignalSet
> 	signal <- sleep 5
> 	print signal
> 	putStrLn "Done."

This, on the other (strange) hand, does:

> import System.Posix
> 
> main = do
> 	putStrLn "Waiting for 5 seconds."
> 	blockSignals fullSignalSet 
> 	signal <- sleep 5
> 	print signal
> 	putStrLn "Done."

- George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090211/221ef498/attachment.bin


More information about the Haskell-Cafe mailing list