X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FSystem.lhs;h=41373d193440b41c7bec0e76c9956d04cace38a7;hb=e921b2e307532e0f30eefa88b11a124be592bde4;hp=0080df6e3f12aeb7f3de3f6792ce8f86c4d33281;hpb=f608faec774d5d2cd895240c1e0e66a48aa6cbe3;p=ghc-hetmet.git diff --git a/ghc/lib/std/System.lhs b/ghc/lib/std/System.lhs index 0080df6..41373d1 100644 --- a/ghc/lib/std/System.lhs +++ b/ghc/lib/std/System.lhs @@ -25,7 +25,7 @@ import Prelude import PrelAddr import PrelIOBase ( IOError(..), IOErrorType(..), constructErrorAndFailWithInfo, stToIO ) import PrelPack ( unpackCString, unpackCStringST, packString ) -import PrelArr ( ByteArray ) +import PrelByteArr ( ByteArray ) type PrimByteArray = ByteArray Int @@ -203,12 +203,6 @@ getProgName = primGetRawArgs >>= \rawargs -> getEnv :: String -> IO String getEnv = primGetEnv -system :: String -> IO ExitCode -system s = error "System.system unimplemented" - -exitWith :: ExitCode -> IO a -exitWith c = error "System.exitWith unimplemented" - exitFailure :: IO a exitFailure = exitWith (ExitFailure 1) @@ -220,6 +214,35 @@ fromExitCode :: ExitCode -> Int fromExitCode ExitSuccess = 0 fromExitCode (ExitFailure n) = n +-- see comment in Prelude.hs near primRunIO_hugs_toplevel +exitWith :: ExitCode -> IO a +exitWith c + = do cleanup_action <- readIORef prelCleanupAfterRunAction + case cleanup_action of + Just xx -> xx + Nothing -> return () + nh_stderr >>= nh_flush + nh_stdout >>= nh_flush + nh_stdin >>= nh_close + nh_exitwith (fromExitCode c) + (ioError.IOError) "System.exitWith: should not return" + +system :: String -> IO ExitCode +system cmd + | null cmd + = (ioError.IOError) "System.system: null command" + | otherwise + = do str <- copy_String_to_cstring cmd + status <- nh_system str + nh_free str + case status of + 0 -> return ExitSuccess + n -> return (ExitFailure n) + +getPID :: IO Int +getPID + = nh_getPID + ----------------------------------------------------------------------------- \end{code} #endif