Work on runplugs. Disable for now

This commit is contained in:
Don Stewart 2005-07-06 04:49:07 +00:00
parent 90c6ce5c4b
commit 68bfb384f6
2 changed files with 21 additions and 6 deletions

View File

@ -8,18 +8,22 @@
-- | Runplugs: use hs-plugins to run a Haskell expression under -- | Runplugs: use hs-plugins to run a Haskell expression under
-- controlled conditions. -- controlled conditions.
-- --
import System.Eval.Haskell (unsafeEval) import System.Eval.Haskell (unsafeEval_)
import Data.Maybe (isJust, fromJust) import Data.Maybe (isJust, fromJust)
import Control.Monad (when) import Control.Monad (when)
import Control.Exception (evaluate)
import System.Exit (exitWith, ExitCode(ExitSuccess)) import System.Exit (exitWith, ExitCode(ExitSuccess))
import System.IO (getContents, putStrLn) import System.IO (hGetContents, hPutStrLn, putStrLn, hClose, stdin, stdout, stderr)
#if !defined(CYGWIN) && !defined(__MINGW32__) #if !defined(CYGWIN) && !defined(__MINGW32__)
import System.Posix.Resource (setResourceLimit, import System.Posix.Resource (setResourceLimit,
Resource(ResourceCPUTime), Resource(ResourceCPUTime),
ResourceLimits(ResourceLimits), ResourceLimits(ResourceLimits),
ResourceLimit(ResourceLimit)) ResourceLimit(ResourceLimit))
import Control.Concurrent ( forkIO )
import qualified Control.Exception ( evaluate )
rlimit = ResourceLimit 3 rlimit = ResourceLimit 3
#endif #endif
@ -41,13 +45,24 @@ datas = map ("Data." ++) [
controls = map ("Control." ++) ["Monad", "Arrow"] controls = map ("Control." ++) ["Monad", "Arrow"]
--
-- with ghc 6.4, ghc doesn't seem to be able to call gcc, setNoFDBlocking fails.
--
-- *** Assembler
-- gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o
--
-- Failed: gcc -I/tmp -c /tmp/ghc11596.s -o /tmp/MySzQ14137.o
-- gcc: setNonBlockingFD: invalid argument (Bad file descriptor)
--
main = do main = do
#if !defined(CYGWIN) && defined(__MINGW32__) #if !defined(CYGWIN) && defined(__MINGW32__)
setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit) setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit)
#endif #endif
s <- getContents s <- hGetContents stdin
when (not . null $ s) $ do when (not . null $ s) $ do
s <- unsafeEval ("(take 2048 (show ("++s++")))") context s <- unsafeEval_ ("(take 2048 (show ("++s++")))") context ["-v"] [] []
when (isJust s) (putStrLn (fromJust s)) case s of
Left errs -> mapM_ putStrLn errs
Right s -> putStrLn s
exitWith ExitSuccess exitWith ExitSuccess

View File

@ -1,4 +1,4 @@
GHCFLAGS= -O $(GHC_EXTRA_OPTS) GHCFLAGS= -Onot $(GHC_EXTRA_OPTS)
PKGFLAGS= -package posix -package-conf $(TOP)/plugins.conf.inplace PKGFLAGS= -package posix -package-conf $(TOP)/plugins.conf.inplace
PKGFLAGS+= -package plugins PKGFLAGS+= -package plugins