1 -----------------------------------------------------------------------------
3 -- Module : System.Exit
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- Exiting the program.
13 -----------------------------------------------------------------------------
17 ExitCode(ExitSuccess,ExitFailure)
18 , exitWith -- :: ExitCode -> IO a
19 , exitFailure -- :: IO a
24 #ifdef __GLASGOW_HASKELL__
40 -- ---------------------------------------------------------------------------
43 -- `exitWith code' terminates the program, returning `code' to the
44 -- program's caller. Before it terminates, any open or semi-closed
45 -- handles are first closed.
48 exitWith :: ExitCode -> IO a
49 exitWith ExitSuccess = throwIO (ExitException ExitSuccess)
50 exitWith code@(ExitFailure n)
51 | n /= 0 = throwIO (ExitException code)
52 #ifdef __GLASGOW_HASKELL__
53 | otherwise = ioError (IOError Nothing InvalidArgument "exitWith" "ExitFailure 0" Nothing)
55 #endif /* ! __NHC__ */
58 exitFailure = exitWith (ExitFailure 1)