From: simonmar Date: Wed, 23 Jan 2002 11:11:13 +0000 (+0000) Subject: [project @ 2002-01-23 11:11:13 by simonmar] X-Git-Tag: Approximately_9120_patches~271 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=c8d8954070a9ed49b1a2c9aeed0662c5dc19ff58;p=ghc-hetmet.git [project @ 2002-01-23 11:11:13 by simonmar] Revert to running command-line statements in the context of the current thread, so that ^C exceptions get delivered to the right place. Now that a deadlock generates an exception this is not so bad, but it would be nice to do it the "right" way so I've left the old code in a comment for now. --- diff --git a/ghc/compiler/compMan/CompManager.lhs b/ghc/compiler/compMan/CompManager.lhs index b79d4de..7eb2c91 100644 --- a/ghc/compiler/compMan/CompManager.lhs +++ b/ghc/compiler/compMan/CompManager.lhs @@ -309,10 +309,22 @@ cmRunStmt cmstate@CmState{ hst=hst, hit=hit, pcs=pcs, pls=pls, ic=icontext } return (cmstate{ pcs=new_pcs, pls=new_pls, ic=new_ic }, CmRunOk names) --- We run the statement in a "sandbox", which amounts to calling into --- the RTS to request a new main thread. The main benefit is that --- there's no danger that exceptions raised by the expression can --- affect the interpreter. + +-- We run the statement in a "sandbox" to protect the rest of the +-- system from anything the expression might do. For now, this +-- consists of just wrapping it in an exception handler, but see below +-- for another version. + +sandboxIO :: IO a -> IO (Either Int (Either Exception a)) +sandboxIO thing = do + r <- Exception.try thing + return (Right r) + +{- +-- This version of sandboxIO runs the expression in a completely new +-- RTS main thread. It is disabled for now because ^C exceptions +-- won't be delivered to the new thread, instead they'll be delivered +-- to the (blocked) GHCi main thread. sandboxIO :: IO a -> IO (Either Int (Either Exception a)) sandboxIO thing = do @@ -331,6 +343,7 @@ sandboxIO thing = do foreign import "rts_evalStableIO" {- safe -} rts_evalStableIO :: StablePtr (IO a) -> Ptr (StablePtr a) -> IO CInt -- more informative than the C type! +-} #endif -----------------------------------------------------------------------------