Just to clarify, here is the sample haskell code that I am using -
{-# LANGUAGE ForeignFunctionInterface #-}
module Glue where
import Foreign.C.String
import qualified Control.Concurrent as CC
funHaskell :: CString -> IO Int
funHaskell cstr = do
putStrLn "Haskell function called"
str <- peekCString cstr
CC.forkIO $ doForever str
CC.threadDelay 2000000
return 0
doForever str = do
putStrLn "Hello World forever"
CC.threadDelay 1000000
doForever str
foreign export stdcall funHaskell :: CString -> IO Int
When I call "funHaskell" from my C program, "Hello World forever" gets printed about twice - I think its because funHaskell waits for about 2 seconds before returning. However, once back in C land, the doForever function stops to execute. I was wondering if there is some setting that would allow the threads sparked to continue execute.
Regards,
Kashyap