From 68bfb384f6c5aaf39d7817edae288efd5b6b7938 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Wed, 6 Jul 2005 04:49:07 +0000 Subject: [PATCH] Work on runplugs. Disable for now --- examples/plugs/runplugs/Main.hs | 25 ++++++++++++++++++++----- examples/plugs/runplugs/Makefile | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/examples/plugs/runplugs/Main.hs b/examples/plugs/runplugs/Main.hs index 538fdfe..9a7e961 100644 --- a/examples/plugs/runplugs/Main.hs +++ b/examples/plugs/runplugs/Main.hs @@ -8,18 +8,22 @@ -- | Runplugs: use hs-plugins to run a Haskell expression under -- controlled conditions. -- -import System.Eval.Haskell (unsafeEval) +import System.Eval.Haskell (unsafeEval_) import Data.Maybe (isJust, fromJust) import Control.Monad (when) +import Control.Exception (evaluate) + 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__) import System.Posix.Resource (setResourceLimit, Resource(ResourceCPUTime), ResourceLimits(ResourceLimits), ResourceLimit(ResourceLimit)) +import Control.Concurrent ( forkIO ) +import qualified Control.Exception ( evaluate ) rlimit = ResourceLimit 3 #endif @@ -41,13 +45,24 @@ datas = map ("Data." ++) [ 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 #if !defined(CYGWIN) && defined(__MINGW32__) setResourceLimit ResourceCPUTime (ResourceLimits rlimit rlimit) #endif - s <- getContents + s <- hGetContents stdin when (not . null $ s) $ do - s <- unsafeEval ("(take 2048 (show ("++s++")))") context - when (isJust s) (putStrLn (fromJust s)) + s <- unsafeEval_ ("(take 2048 (show ("++s++")))") context ["-v"] [] [] + case s of + Left errs -> mapM_ putStrLn errs + Right s -> putStrLn s exitWith ExitSuccess diff --git a/examples/plugs/runplugs/Makefile b/examples/plugs/runplugs/Makefile index 5ccabfe..2f4e702 100644 --- a/examples/plugs/runplugs/Makefile +++ b/examples/plugs/runplugs/Makefile @@ -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 plugins