Skip to content

usleep hangs, no threads

import System.Posix.Unistd main = flip mapM_ [0..] $ \i -> do

usleep 100000

print i

The above program hangs after a variable number of iterations (usually around 120, sometimes up to 200, often before the first call to print).

The documentation for usleep warns about bad interactions with threads, but the above program doesn't use any.

The problem also occurs with nanosleep, but not with threadDelay.

#1156 (closed) sounds related, but this time the problem also occurs without -threaded.

workaround: use threadDelay.

Trac metadata
Trac field Value
Version 7.4.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information