How to to terminate runStmt in "GHC as a library"

Mads Lindstrøm mads_lindstroem at
Sun May 20 15:11:43 EDT 2007

Hi all

I am trying to build a GUI for GHCi using "GHC as a library". See .

One requirement is that the GUI is still responsive when executing code
using GHC.runStmt. Therefore I do:

   forkIO $ GHC.runStmt someStatement >> return()

While this works fine, it does give me one problem. How do I terminate a
call to runStmt prematurely? One would think that this would work:

   threadId <-forkIO $ GHC.runStmt someStatement >> return()
   killThread threadId

However, as runStmt also uses forkIO internally I am not killing the
thread that runs "someStatement" - actually nothing seems to happen when
executing the action "killThread threadId".

Anybody knows how to kill the thread running "someStatement"?

I have attached a more complete program which illustrates the problem
described above. I have only tested the program on Debian/Linux.


Mads Lindstrøm

-------------- next part --------------
A non-text attachment was scrubbed...
Name: StopingRunStmt.hs
Type: text/x-haskell
Size: 1867 bytes
Desc: not available
Url :

More information about the Glasgow-haskell-users mailing list