1 -----------------------------------------------------------------------------
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/core/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- Executing a command.
13 -----------------------------------------------------------------------------
16 ( system -- :: String -> IO ExitCode
24 #ifdef __GLASGOW_HASKELL__
28 -- ---------------------------------------------------------------------------
31 -- Computation `system cmd' returns the exit code
32 -- produced when the operating system processes the command `cmd'.
34 -- This computation may fail with
36 -- The process has insufficient privileges to perform the operation.
38 -- Insufficient resources are available to perform the operation.
39 -- UnsupportedOperation
40 -- The implementation does not support system calls.
42 system :: String -> IO ExitCode
43 system "" = ioException (IOError Nothing InvalidArgument "system" "null command" Nothing)
45 withCString cmd $ \s -> do
46 status <- throwErrnoIfMinus1 "system" (primSystem s)
48 0 -> return ExitSuccess
49 n -> return (ExitFailure n)
51 foreign import ccall unsafe "systemCmd" primSystem :: CString -> IO Int