-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A replacement for System.Exit and System.Process. -- @package sys-process @version 0.1.2 module Sys.ExitCode type ExitCode = Number Int _ExitFailure :: Prism' ExitCode (NotZero Int) _ExitSuccess :: Prism' ExitCode () exitFailure :: NotZero Int -> ExitCode exitSuccess :: ExitCode exitFailureP :: Prism' ExitCode Int exitSuccessP :: Prism' ExitCode () exitCode :: ExitCode -> ExitCode unExitCode :: ExitCode -> ExitCode module Sys.StdStream data StdStream -- | Inherit Handle from parent Inherit :: StdStream -- | Use the supplied Handle UseHandle :: Handle -> StdStream -- | Create a new pipe. The returned Handle will use the default -- encoding and newline translation mode (just like Handles -- created by openFile). CreatePipe :: StdStream class AsStdStream p f s _StdStream :: AsStdStream p f s => Optic' p f s StdStream class AsInherit p f s _Inherit :: AsInherit p f s => Optic' p f s () class AsUseHandle p f s _UseHandle :: AsUseHandle p f s => Optic' p f s Handle class AsCreatePipe p f s instance Eq StdStream instance Show StdStream instance (Choice p, Applicative f) => AsCreatePipe p f StdStream instance AsCreatePipe p f () instance (Choice p, Applicative f) => AsUseHandle p f StdStream instance AsUseHandle p f Handle instance (Choice p, Applicative f) => AsInherit p f StdStream instance AsInherit p f () instance (Profunctor p, Functor f) => AsStdStream p f StdStream instance AsStdStream p f StdStream module Sys.CmdSpec data CmdSpec -- | A command line to execute using the shell ShellCommand :: String -> CmdSpec -- | The name of an executable with a list of arguments -- -- The FilePath argument names the executable, and is interpreted -- according to the platform's standard policy for searching for -- executables. Specifically: -- -- RawCommand :: FilePath -> [String] -> CmdSpec class AsCmdSpec p f s _CmdSpec :: AsCmdSpec p f s => Optic' p f s CmdSpec class AsExecutableName p f s _ExecutableName :: AsExecutableName p f s => Optic' p f s FilePath class AsExecutableArguments p f s _ExecutableArguments :: AsExecutableArguments p f s => Optic' p f s [String] class AsShellCommand p f s _ShellCommand :: AsShellCommand p f s => Optic' p f s String class AsRawCommand p f s _RawCommand :: AsRawCommand p f s => Optic' p f s (FilePath, [String]) instance Eq CmdSpec instance Ord CmdSpec instance Show CmdSpec instance (Choice p, Applicative f) => AsRawCommand p f CmdSpec instance AsRawCommand p f (FilePath, [String]) instance (Choice p, Applicative f) => AsShellCommand p f CmdSpec instance AsShellCommand p f String instance Applicative f => AsExecutableArguments (->) f CmdSpec instance AsExecutableArguments p f [String] instance Applicative f => AsExecutableName (->) f CmdSpec instance AsExecutableName p f FilePath instance (Profunctor p, Functor f) => AsCmdSpec p f CmdSpec instance AsCmdSpec p f CmdSpec instance IsString CmdSpec module Sys.CreateProcess data CreateProcess CreateProcess :: CmdSpec -> (Maybe FilePath) -> (Maybe [(String, String)]) -> StdStream -> StdStream -> StdStream -> Bool -> Bool -> Bool -> CreateProcess class AsCreateProcess p f s _CreateProcess :: AsCreateProcess p f s => Optic' p f s CreateProcess class AsWorkingDirectory p f s _WorkingDirectory :: AsWorkingDirectory p f s => Optic' p f s (Maybe FilePath) class AsEnvironment p f s _Environment :: AsEnvironment p f s => Optic' p f s (Maybe [(String, String)]) class AsStdin p f s _Stdin :: AsStdin p f s => Optic' p f s StdStream class AsStdout p f s _Stdout :: AsStdout p f s => Optic' p f s StdStream class AsStderr p f s _Stderr :: AsStderr p f s => Optic' p f s StdStream class AsCloseDescriptors p f s _CloseDescriptors :: AsCloseDescriptors p f s => Optic' p f s Bool class AsCreateGroup p f s _CreateGroup :: AsCreateGroup p f s => Optic' p f s Bool class AsDelegateCtrlC p f s _DelegateCtrlC :: AsDelegateCtrlC p f s => Optic' p f s Bool instance Eq CreateProcess instance Show CreateProcess instance Functor f => AsDelegateCtrlC (->) f CreateProcess instance AsDelegateCtrlC p f Bool instance Functor f => AsCreateGroup (->) f CreateProcess instance AsCreateGroup p f Bool instance Functor f => AsCloseDescriptors (->) f CreateProcess instance AsCloseDescriptors p f Bool instance Functor f => AsStderr (->) f CreateProcess instance AsStderr p f StdStream instance Functor f => AsStdout (->) f CreateProcess instance AsStdout p f StdStream instance Functor f => AsStdin (->) f CreateProcess instance AsStdin p f StdStream instance Functor f => AsEnvironment (->) f CreateProcess instance AsEnvironment p f (Maybe [(String, String)]) instance Functor f => AsWorkingDirectory (->) f CreateProcess instance AsWorkingDirectory p f (Maybe FilePath) instance Applicative f => AsRawCommand (->) f CreateProcess instance Applicative f => AsShellCommand (->) f CreateProcess instance Applicative f => AsExecutableArguments (->) f CreateProcess instance Applicative f => AsExecutableName (->) f CreateProcess instance Functor f => AsCmdSpec (->) f CreateProcess instance (Profunctor p, Functor f) => AsCreateProcess p f CreateProcess instance AsCreateProcess p f CreateProcess module Sys.Process createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) createProcess_ :: String -> CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) shell :: String -> CreateProcess proc :: FilePath -> [String] -> CreateProcess -- | Creates a new process to run the specified command with the given -- arguments, and wait for it to finish. If the command returns a -- non-zero exit code, an exception is raised. -- -- If an asynchronous exception is thrown to the thread executing -- callProcess. The forked process will be terminated and -- callProcess will wait (block) until the process has been -- terminated. -- -- Since: 1.2.0.0 callProcess :: FilePath -> [String] -> IO () -- | Creates a new process to run the specified shell command. If the -- command returns a non-zero exit code, an exception is raised. -- -- If an asynchronous exception is thrown to the thread executing -- callCommand. The forked process will be terminated and -- callCommand will wait (block) until the process has been -- terminated. -- -- Since: 1.2.0.0 callCommand :: String -> IO () -- | Creates a new process to run the specified raw command with the given -- arguments. It does not wait for the program to finish, but returns the -- ProcessHandle. -- -- Since: 1.2.0.0 spawnProcess :: FilePath -> [String] -> IO ProcessHandle -- | Creates a new process to run the specified shell command. It does not -- wait for the program to finish, but returns the ProcessHandle. -- -- Since: 1.2.0.0 spawnCommand :: String -> IO ProcessHandle readCreateProcess :: CreateProcess -> String -> IO String -- | readProcess forks an external process, reads its standard -- output strictly, blocking until the process terminates, and returns -- the output string. The external process inherits the standard error. -- -- If an asynchronous exception is thrown to the thread executing -- readProcess, the forked process will be terminated and -- readProcess will wait (block) until the process has been -- terminated. -- -- Output is returned strictly, so this is not suitable for interactive -- applications. -- -- This function throws an IOError if the process ExitCode -- is anything other than ExitSuccess. If instead you want to get -- the ExitCode then use readProcessWithExitCode. -- -- Users of this function should compile with -threaded if they -- want other Haskell threads to keep running while waiting on the result -- of readProcess. -- --
--   > readProcess "date" [] []
--   "Thu Feb  7 10:03:39 PST 2008\n"
--   
-- -- The arguments are: -- -- readProcess :: FilePath -> [String] -> String -> IO String readCreateProcessWithExitCode :: CreateProcess -> String -> IO (ExitCode, String, String) readProcessWithExitCode :: FilePath -> [String] -> String -> IO (ExitCode, String, String) -- | Given a program p and arguments args, -- showCommandForUser p args returns a string -- suitable for pasting into /bin/sh (on Unix systems) or -- CMD.EXE (on Windows). showCommandForUser :: FilePath -> [String] -> String waitForProcess :: ProcessHandle -> IO ExitCode getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode) -- | Attempts to terminate the specified process. This function should not -- be used under normal circumstances - no guarantees are given regarding -- how cleanly the process is terminated. To check whether the process -- has indeed terminated, use getProcessExitCode. -- -- On Unix systems, terminateProcess sends the process the SIGTERM -- signal. On Windows systems, the Win32 TerminateProcess -- function is called, passing an exit code of 1. -- -- Note: on Windows, if the process was a shell command created by -- createProcess with shell, or created by -- runCommand or runInteractiveCommand, then -- terminateProcess will only terminate the shell, not the command -- itself. On Unix systems, both processes are in a process group and -- will be terminated together. terminateProcess :: ProcessHandle -> IO () -- | Sends an interrupt signal to the process group of the given process. -- -- On Unix systems, it sends the group the SIGINT signal. -- -- On Windows systems, it generates a CTRL_BREAK_EVENT and will only work -- for processes created using createProcess and setting the -- create_group flag interruptProcessGroupOf :: ProcessHandle -> IO () -- | Create a pipe for interprocess communication and return a -- (readEnd, writeEnd) Handle pair. -- -- Since: 1.2.1.0 createPipe :: IO (Handle, Handle) module Sys.Exit data ProcessHandle :: * -- | Computation exitWith code throws ExitCode -- code. Normally this terminates the program, returning -- code to the program's caller. -- -- On program termination, the standard Handles stdout and -- stderr are flushed automatically; any other buffered -- Handles need to be flushed manually, otherwise the buffered -- data will be discarded. -- -- A program that fails in any other way is treated as if it had called -- exitFailure. A program that terminates successfully without -- calling exitWith explicitly is treated as it it had called -- exitWith ExitSuccess. -- -- As an ExitCode is not an IOError, exitWith -- bypasses the error handling in the IO monad and cannot be -- intercepted by catch from the Prelude. However it is a -- SomeException, and can be caught using the functions of -- Control.Exception. This means that cleanup computations added -- with bracket (from Control.Exception) are also executed -- properly on exitWith. -- -- Note: in GHC, exitWith should be called from the main program -- thread in order to exit the process. When called from another thread, -- exitWith will throw an ExitException as normal, but -- the exception will not cause the process itself to exit. exitWith :: ExitCode -> IO a exitWithFailure :: NotZero Int -> IO a -- | The computation exitWithFailure1 is equivalent to -- exitWith (ExitFailure -- exitfail), where exitfail is -- implementation-dependent. exitWithFailure1 :: IO a -- | The computation exitWithSuccess is equivalent to -- exitWith ExitSuccess, It terminates the program -- successfully. exitWithSuccess :: IO a