[nhc-bugs] System.system

Ian Lynagh igloo at earth.li
Tue Feb 10 23:37:02 EST 2004


Hi,

In src/prelude/System/SystemFun.hs the OS's system function is called to
implement System.system. However, the various checks are not done and
WEXITSTATUS is not applied as appropriate.

It looks like src/runtime/Builtin/cSystem.c does the same thing.

src/libraries/base/System/Cmd.hs uses systemCmd when __GLASGOW_HASKELL__
is defined, which is defined in libraries/base/cbits/system.c. This
looks like it is doing the right stuff.

This causes this:

-----8<----------8<----------8<----------8<-----
main :: IO ()
main = mapM_ f [0..5]

f :: Int -> IO ()
f i = do x <- system $ "exit " ++ show i
         print x
-----8<----------8<----------8<----------8<-----

to output this for me:

ExitSuccess
ExitFailure 256
ExitFailure 512
ExitFailure 768
ExitFailure 1024
ExitFailure 1280


Thanks
Ian



More information about the Nhc-bugs mailing list