[Haskell-cafe] Safe FFI calls, -threaded and killThread
ekarttun at cs.helsinki.fi
Tue Oct 25 04:07:27 EDT 2005
I noticed that killThread in GHC behaves in a problematic fashion with
-threaded when the killed thread is in a midle of performing a safe
FFI call. If the behaviour (blocking until the call is done) is intended
adding documentation might be nice.
The example below demonstrates the problem. Tthe program gets stuck
in the killThread call which is not very intuitive. Wrapping every
killThread in forkIO does not sound very nice either.
- Einar Karttunen
foreign import ccall threadsafe "sleep" sleep :: CInt -> IO CInt
main = do mv <- newEmptyMVar
tid <- forkIO $ sleep 100 >> putMVar mv ()
e <- isEmptyMVar mv
if e then do putStrLn "killing sleeper"
else do putStrLn "sleeper already done"
More information about the Haskell-Cafe