[project @ 2000-05-22 13:09:29 by simonmar]
[ghc-hetmet.git] / ghc / lib / std / System.lhs
index ba31873..61955b0 100644 (file)
@@ -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
 
@@ -137,6 +137,8 @@ exitWith (ExitFailure n)
     primExit n
     ioError (IOError Nothing OtherError "exitWith" "exit should not return")
 
+-- NOTE: shutdownHaskellAndExit must be called "safe", because it *can*
+-- re-enter Haskell land through finalizers.
 foreign import ccall "shutdownHaskellAndExit" primExit :: Int -> IO ()
 
 exitFailure :: IO a
@@ -188,13 +190,29 @@ unpackProgName argv
 --
 -- Suitable for use with Hugs 98
 -----------------------------------------------------------------------------
+import PrelPrim ( primGetRawArgs
+               , primGetEnv
+               , prelCleanupAfterRunAction
+               , copy_String_to_cstring
+               , readIORef
+               , nh_stderr
+               , nh_stdout
+               , nh_stdin 
+               , nh_exitwith 
+               , nh_flush
+               , nh_close
+               , nh_system
+               , nh_free
+               , nh_getPID
+               )
+
 
 data ExitCode = ExitSuccess | ExitFailure Int
                 deriving (Eq, Ord, Read, Show)
 
 getArgs                     :: IO [String]
 getArgs                      = primGetRawArgs >>= \rawargs ->
-                               return (drop 1 (dropWhile (/= "--") rawargs))
+                               return (tail rawargs)
 
 getProgName                 :: IO String
 getProgName                  = primGetRawArgs >>= \rawargs ->
@@ -217,7 +235,7 @@ fromExitCode (ExitFailure n) = n
 -- see comment in Prelude.hs near primRunIO_hugs_toplevel
 exitWith :: ExitCode -> IO a
 exitWith c
-   = do cleanup_action <- readIORef prelExitWithAction
+   = do cleanup_action <- readIORef prelCleanupAfterRunAction
         case cleanup_action of
            Just xx -> xx
            Nothing -> return ()