-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Monad transformer for exit codes -- -- -- Monad transformer for exit codes @package exitcode @version 0.1.0.9 module Control.Exitcode -- | An exit code status where failing with a value `0` cannot be -- represented. -- -- Transformer for either a (non-zero exit code value (Int) with -- error :: e) or a (value :: a). data ExitcodeT f e a type Exitcode e a = ExitcodeT Identity e a type ExitcodeT0 f = ExitcodeT f () () type Exitcode0 = Exitcode () () type ExitcodeT1 f a = ExitcodeT f a a type Exitcode1 a = ExitcodeT1 Identity a -- | Construct a succeeding exit code with the given value. -- --
--   >>> exitsuccess "abc" :: ExitcodeT Identity () String
--   ExitcodeT (Identity (Right "abc"))
--   
exitsuccess :: Applicative f => a -> ExitcodeT f e a -- | Construct a succeeding exit code with unit. -- --
--   >>> exitsuccess0 :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Right ()))
--   
exitsuccess0 :: Applicative f => ExitcodeT f e () -- | Construct a failing exit code with the given status. -- -- If the given status is `0` then the exit code will succeed with unit. -- --
--   >>> exitfailure 'x' 99 :: ExitcodeT Identity Char ()
--   ExitcodeT (Identity (Left ('x',99)))
--   
exitfailure :: Applicative f => e -> Int -> ExitcodeT f e () -- | Construct a failing exit code with the given status. -- -- If the given status is `0` then the exit code will succeed with unit. exitfailure0 :: Applicative f => Int -> ExitcodeT0 f -- | Construct an exit code with the given status. Associate a value of -- type e with a failing exit code and a value of the type -- a with a success exit code. -- -- If the given status is `0` then the exit code will succeed with unit. -- >>> exitcodeValue x 99 "abc" :: ExitcodeT Identity -- Char String ExitcodeT (Identity (Left (x,99))) >>> -- exitcodeValue x 0 "abc" :: ExitcodeT Identity Char String -- ExitcodeT (Identity (Right "abc")) exitcodeValue :: Applicative f => e -> Int -> a -> ExitcodeT f e a -- | Construct an exit code with the given status. -- -- If the given status is `0` then the exit code will succeed with unit. -- --
--   >>> exitcodeValue0 99 :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Left ((),99)))
--   
--   >>> exitcodeValue0 0 :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Right ()))
--   
exitcodeValue0 :: Applicative f => Int -> ExitcodeT0 f -- | From base exitcode. -- --
--   >>> fromExitCode (Identity ExitSuccess)
--   ExitcodeT (Identity (Right ()))
--   
--   >>> fromExitCode (Identity (ExitFailure 99))
--   ExitcodeT (Identity (Left ((),99)))
--   
fromExitCode :: Functor f => f ExitCode -> ExitcodeT0 f -- | From base exitcode. -- --
--   >>> fromExitCode' ExitSuccess
--   ExitcodeT (Identity (Right ()))
--   
--   >>> fromExitCode' (ExitFailure 99)
--   ExitcodeT (Identity (Left ((),99)))
--   
--   >>> fromExitCode' (ExitFailure 0)
--   ExitcodeT (Identity (Right ()))
--   
fromExitCode' :: ExitCode -> Exitcode0 liftExitcode :: Functor f => f a -> ExitcodeT f e a liftExitcodeError :: Functor f => f (e, Int) -> a -> ExitcodeT f e a liftExitcodeError0 :: Functor f => f Int -> ExitcodeT f () () hoistExitcode :: (forall x. f x -> g x) -> ExitcodeT f e a -> ExitcodeT g e a embedExitcode :: Functor g => (forall x. f x -> ExitcodeT g e x) -> ExitcodeT f e a -> ExitcodeT g e a -- | Construct an exitcode with an associated value. -- --
--   >>> exitcode1 99 "abc" :: ExitcodeT1 Identity String
--   ExitcodeT (Identity (Left ("abc",99)))
--   
--   >>> exitcode1 0 "abc" :: ExitcodeT1 Identity String
--   ExitcodeT (Identity (Right "abc"))
--   
exitcode1 :: Applicative f => Int -> a -> ExitcodeT1 f a -- | Extract either the non-zero value or the success value. -- --
--   >>> runExitcodeT exitsuccess0 :: Identity (Either ((), Int) ())
--   Identity (Right ())
--   
--   >>> runExitcodeT (exitfailure () 99) :: Identity (Either ((), Int) ())
--   Identity (Left ((),99))
--   
runExitcodeT :: ExitcodeT f e a -> f (Either (e, Int) a) -- | Extract either the non-zero value or Nothing. -- --
--   >>> runExitcodeT0 exitsuccess0 :: Identity (Maybe Int)
--   Identity Nothing
--   
--   >>> runExitcodeT0 (exitfailure () 99) :: Identity (Maybe Int)
--   Identity (Just 99)
--   
runExitcodeT0 :: Functor f => ExitcodeT0 f -> f (Maybe Int) -- | Extract either the non-zero value or the success value. -- --
--   >>> runExitcode exitsuccess0 :: Either ((), Int) ()
--   Right ()
--   
--   >>> runExitcode (exitfailure () 99) :: Either ((), Int) ()
--   Left ((),99)
--   
runExitcode :: Exitcode e a -> Either (e, Int) a -- | Extract either the non-zero value or Nothing. -- --
--   >>> runExitcode0 exitsuccess0 :: Maybe Int
--   Nothing
--   
--   >>> runExitcode0 (exitfailure () 99) :: Maybe Int
--   Just 99
--   
runExitcode0 :: Exitcode0 -> Maybe Int -- | Extract either the non-zero value or the success value. -- --
--   >>> runExitcodeT1 exitsuccess0
--   Right ()
--   
--   >>> runExitcodeT1 (exitfailure () 99) :: Identity (Either ((), Int) ())
--   Identity (Left ((),99))
--   
--   >>> runExitcodeT1 (exitcode1 0 "abc") :: Identity (Either (String, Int) String)
--   Identity (Right "abc")
--   
--   >>> runExitcodeT1 (exitcode1 99 "abc") :: Identity (Either (String, Int) String)
--   Identity (Left ("abc",99))
--   
runExitcodeT1 :: ExitcodeT1 f a -> f (Either (a, Int) a) -- | Extract either the non-zero value or the success value. -- --
--   >>> runExitcode1 exitsuccess0
--   Right ()
--   
--   >>> runExitcode1 (exitfailure () 99)
--   Left ((),99)
--   
--   >>> runExitcode1 (exitcode1 0 "abc")
--   Right "abc"
--   
--   >>> runExitcode1 (exitcode1 99 "abc")
--   Left ("abc",99)
--   
runExitcode1 :: Exitcode1 a -> Either (a, Int) a -- | Try the IO action producing the exitcode, possibly throwing an -- exception. tryExitcode :: Exception e' => ExitcodeT IO e a -> ExitcodeT (ExceptT e' IO) e a -- | Try the IO action producing the exitcode, possibly throwing an -- exception. liftTryExitcode :: Exception e' => IO a -> ExitcodeT (ExceptT e' IO) e a -- | Isomorphism from base exitcode to underlying `Maybe (Either Int ())` -- where Int is non-zero. -- --
--   >>> view exitCode (Identity (ExitFailure 99))
--   ExitcodeT (MaybeT (Identity (Just (Left ((),99)))))
--   
--   >>> view exitCode (Identity ExitSuccess)
--   ExitcodeT (MaybeT (Identity (Just (Right ()))))
--   
--   >>> Control.Lens.review exitCode (exitfailure () 99) :: Identity ExitCode
--   Identity (ExitFailure 99)
--   
--   >>> Control.Lens.review exitCode exitsuccess0 :: Identity ExitCode
--   Identity ExitSuccess
--   
exitCode :: (Functor f, Functor g) => Iso (f ExitCode) (g ExitCode) (ExitcodeT0 (MaybeT f)) (ExitcodeT0 (MaybeT g)) -- | Isomorphism to integer. -- --
--   >>> view _ExitcodeInt exitsuccess0 :: [Int]
--   [0]
--   
--   >>> view _ExitcodeInt (exitfailure0 99) :: [Int]
--   [99]
--   
--   >>> review _ExitcodeInt [0]
--   ExitcodeT [Right ()]
--   
--   >>> review _ExitcodeInt [99]
--   ExitcodeT [Left ((),99)]
--   
_ExitcodeInt :: (Functor f, Functor f') => Iso (ExitcodeT0 f) (ExitcodeT0 f') (f Int) (f' Int) -- | Setter to integer. -- --
--   >>> > preview _ExitcodeInt' (exitsuccess0 :: ExitcodeT [] () ())
--   Just 0
--   
--   >>> preview _ExitcodeInt' (exitfailure0 99 :: ExitcodeT [] () ())
--   Just 99
--   
--   >>> preview _ExitcodeInt' (exitfailure0 0 :: ExitcodeT [] () ())
--   Just 0
--   
--   >>> over _ExitcodeInt' (subtract 1) exitsuccess0 :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Left ((),-1)))
--   
--   >>> over _ExitcodeInt' (subtract 1) (exitfailure0 99) :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Left ((),98)))
--   
--   >>> over _ExitcodeInt' (subtract 1) (exitfailure0 1) :: ExitcodeT0 Identity
--   ExitcodeT (Identity (Right ()))
--   
_ExitcodeInt' :: Traversable f => Traversal' (ExitcodeT0 f) Int -- | A traversal to exit failure. -- --
--   >>> preview _ExitFailure (exitfailure () 99 :: ExitcodeT0 Identity)
--   Just ((),99)
--   
--   >>> preview _ExitFailure (exitsuccess0 :: ExitcodeT0 Identity)
--   Nothing
--   
--   >>> over _ExitFailure (\(e, n) -> (e + 1, n + 1)) (exitsuccess0 :: ExitcodeT Identity Int ())
--   ExitcodeT (Identity (Right ()))
--   
--   >>> over _ExitFailure (\(e, n) -> (reverse e, n + 1)) (exitfailure "abc" 1 :: ExitcodeT Identity String ())
--   ExitcodeT (Identity (Left ("cba",2)))
--   
--   >>> over _ExitFailure (\(e, n) -> (reverse e, n - 1)) (exitfailure "abc" 1 :: ExitcodeT Identity String ())
--   ExitcodeT (Identity (Right ()))
--   
_ExitFailure :: Traversable f => Traversal (ExitcodeT f e ()) (ExitcodeT f e' ()) (e, Int) (e', Int) -- | A traversal over the associated failing value. -- --
--   >>> over _ExitFailureError reverse exitsuccess0 :: ExitcodeT Identity [Int] ()
--   ExitcodeT (Identity (Right ()))
--   
--   >>> over _ExitFailureError reverse (exitfailure "abc" 99) :: ExitcodeT Identity String ()
--   ExitcodeT (Identity (Left ("cba",99)))
--   
--   >>> over _ExitFailureError reverse (exitfailure "abc" 0) :: ExitcodeT Identity String ()
--   ExitcodeT (Identity (Right ()))
--   
--   >>> preview _ExitFailureError (exitfailure () 99 :: ExitcodeT0 Identity)
--   Just ()
--   
--   >>> preview _ExitFailureError (exitsuccess0 :: ExitcodeT0 Identity)
--   Nothing
--   
_ExitFailureError :: Traversable f => Traversal (ExitcodeT f e a) (ExitcodeT f e' a) e e' -- | A prism to exit success. -- --
--   >>> over _ExitSuccess (\x -> x) (exitfailure0 99)
--   ExitcodeT (Identity (Left ((),99)))
--   
--   >>> over _ExitSuccess (\x -> x) (exitfailure0 0)
--   ExitcodeT (Identity (Right ()))
--   
--   >>> over _ExitSuccess (\x -> x) (exitfailure0 0)
--   ExitcodeT (Identity (Right ()))
--   
--   >>> preview _ExitSuccess (exitfailure () 99)
--   Nothing
--   
--   >>> preview _ExitSuccess exitsuccess0
--   Just ()
--   
--   >>> Control.Lens.review _ExitSuccess "abc" :: ExitcodeT Identity () String
--   ExitcodeT (Identity (Right "abc"))
--   
_ExitSuccess :: Prism (Exitcode e a) (Exitcode e a') a a' -- | A lens to the value associated with an exitcode. -- --
--   >>> view _Exitcode1 (exitcode1 0 "abc")
--   "abc"
--   
--   >>> view _Exitcode1 (exitcode1 99 "abc")
--   "abc"
--   
--   >>> view _Exitcode1 (exitcodeValue "abc" 0 "def")
--   "def"
--   
--   >>> view _Exitcode1 (exitcodeValue "abc" 99 "def")
--   "abc"
--   
--   >>> over _Exitcode1 reverse (exitcode1 0 "abc")
--   ExitcodeT (Identity (Right "cba"))
--   
--   >>> over _Exitcode1 reverse (exitcode1 99 "abc")
--   ExitcodeT (Identity (Left ("cba",99)))
--   
--   >>> over _Exitcode1 reverse (exitcodeValue "abc" 0 "def")
--   ExitcodeT (Identity (Right "fed"))
--   
--   >>> over _Exitcode1 reverse (exitcodeValue "abc" 99 "def")
--   ExitcodeT (Identity (Left ("cba",99)))
--   
_Exitcode1 :: Lens (Exitcode1 a) (Exitcode1 a') a a' instance GHC.Base.Functor f => GHC.Base.Functor (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Monad f => Data.Functor.Bind.Class.Apply (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Monad f => GHC.Base.Applicative (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Monad f => Data.Functor.Bind.Class.Bind (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Monad f => GHC.Base.Monad (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Monad f => Data.Functor.Alt.Alt (Control.Exitcode.ExitcodeT f e) instance (GHC.Base.Semigroup a, GHC.Base.Applicative f) => GHC.Base.Semigroup (Control.Exitcode.ExitcodeT f e a) instance (GHC.Base.Monoid a, GHC.Base.Applicative f) => GHC.Base.Monoid (Control.Exitcode.ExitcodeT f e a) instance Data.Functor.Extend.Extend f => Data.Functor.Extend.Extend (Control.Exitcode.ExitcodeT f e) instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (Control.Exitcode.ExitcodeT f e a) instance (Data.Functor.Classes.Eq1 f, GHC.Classes.Eq e) => Data.Functor.Classes.Eq1 (Control.Exitcode.ExitcodeT f e) instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord e, GHC.Classes.Ord a) => GHC.Classes.Ord (Control.Exitcode.ExitcodeT f e a) instance (Data.Functor.Classes.Ord1 f, GHC.Classes.Ord e) => Data.Functor.Classes.Ord1 (Control.Exitcode.ExitcodeT f e) instance (Data.Functor.Classes.Show1 f, GHC.Show.Show e, GHC.Show.Show a) => GHC.Show.Show (Control.Exitcode.ExitcodeT f e a) instance (Data.Functor.Classes.Show1 f, GHC.Show.Show e) => Data.Functor.Classes.Show1 (Control.Exitcode.ExitcodeT f e) instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Exitcode.ExitcodeT f e) instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Exitcode.ExitcodeT f e) instance Control.Monad.IO.Class.MonadIO f => Control.Monad.IO.Class.MonadIO (Control.Exitcode.ExitcodeT f e) instance Control.Monad.Reader.Class.MonadReader r f => Control.Monad.Reader.Class.MonadReader r (Control.Exitcode.ExitcodeT f e) instance Control.Monad.Writer.Class.MonadWriter w f => Control.Monad.Writer.Class.MonadWriter w (Control.Exitcode.ExitcodeT f e) instance Control.Monad.State.Class.MonadState s f => Control.Monad.State.Class.MonadState s (Control.Exitcode.ExitcodeT f e) instance Control.Monad.Error.Class.MonadError e f => Control.Monad.Error.Class.MonadError e (Control.Exitcode.ExitcodeT f e') instance Control.Monad.RWS.Class.MonadRWS r w s f => Control.Monad.RWS.Class.MonadRWS r w s (Control.Exitcode.ExitcodeT f e) instance Control.Monad.Cont.Class.MonadCont f => Control.Monad.Cont.Class.MonadCont (Control.Exitcode.ExitcodeT f e) instance GHC.Base.Functor f => Data.Bifunctor.Bifunctor (Control.Exitcode.ExitcodeT f) instance Data.Foldable.Foldable f => Data.Bifoldable.Bifoldable (Control.Exitcode.ExitcodeT f) instance Data.Traversable.Traversable f => Data.Bitraversable.Bitraversable (Control.Exitcode.ExitcodeT f) module Control.Process.CmdSpec class AsCmdSpec a _CmdSpec :: AsCmdSpec a => Prism' a CmdSpec _ShellCommand :: AsCmdSpec a => Prism' a String _RawCommand :: AsCmdSpec a => Prism' a (FilePath, [String]) _RawCommandExe :: AsCmdSpec a => Traversal' a FilePath _RawCommandArgumentList :: AsCmdSpec a => Traversal' a [String] _RawCommandArguments :: AsCmdSpec a => Traversal' a String class HasCmdSpec a cmdSpec :: HasCmdSpec a => Lens' a CmdSpec shellCommand :: HasCmdSpec a => Traversal' a String rawCommand :: HasCmdSpec a => Traversal' a (FilePath, [String]) rawCommandExe :: HasCmdSpec a => Traversal' a FilePath rawCommandArgumentList :: HasCmdSpec a => Traversal' a [String] rawCommandArguments :: HasCmdSpec a => Traversal' a String instance Control.Process.CmdSpec.HasCmdSpec System.Process.Common.CmdSpec instance Control.Process.CmdSpec.HasCmdSpec System.Process.Common.CreateProcess instance Control.Process.CmdSpec.AsCmdSpec System.Process.Common.CmdSpec module Control.Process.FD class HasFD a fd :: HasFD a => Lens' a FD fdInt32 :: HasFD a => Lens' a Int32 class AsFD a _FD :: AsFD a => Prism' a FD _FDInt32 :: AsFD a => Prism' a Int32 instance Control.Process.FD.AsFD System.Posix.Internals.FD instance Control.Process.FD.HasFD System.Posix.Internals.FD module Control.Process.GroupID class HasGroupID a groupID :: HasGroupID a => Lens' a GroupID class AsGroupID a _GroupID :: AsGroupID a => Prism' a GroupID instance Control.Process.GroupID.AsGroupID System.Posix.Types.GroupID instance Control.Process.GroupID.HasGroupID System.Posix.Types.GroupID module Control.Process.Handle class HasHandle a handle :: HasHandle a => Lens' a Handle class AsHandle a _Handle :: AsHandle a => Prism' a Handle instance Control.Process.Handle.AsHandle GHC.IO.Handle.Types.Handle instance Control.Process.Handle.AsHandle System.Process.Common.StdStream instance Control.Process.Handle.HasHandle GHC.IO.Handle.Types.Handle module Control.Process.Pid class HasPid a pid :: HasPid a => Lens' a Pid pidInt32 :: HasPid a => Lens' a Int32 class AsPid a _Pid :: AsPid a => Prism' a Pid _PidInt32 :: AsPid a => Prism' a Int32 instance Control.Process.Pid.AsPid System.Process.Pid instance Control.Process.Pid.HasPid System.Process.Pid module Control.Process.Process -- | The platform specific type for a process identifier. -- -- This is always an integral type. Width and signedness are platform -- specific. type Pid = CPid -- | A bracket-style resource handler for createProcess. -- -- Does automatic cleanup when the action finishes. If there is an -- exception in the body then it ensures that the process gets terminated -- and any CreatePipe Handles are closed. In particular -- this means that if the Haskell thread is killed (e.g. -- killThread), that the external process is also terminated. -- -- e.g. -- --
--   withCreateProcess (proc cmd args) { ... }  $ \stdin stdout stderr ph -> do
--     ...
--   
withCreateProcess :: CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> IO a) -> IO a -- | 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, if use_process_jobs is True -- then the Win32 TerminateJobObject function is called to kill -- all processes associated with the job and passing the exit code of 1 -- to each of them. Otherwise if use_process_jobs is False -- then 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 () -- | 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. spawnProcess :: FilePath -> [String] -> IO ProcessHandle -- | 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 -- | Construct a CreateProcess record for passing to -- createProcess, representing a command to be passed to the -- shell. shell :: String -> CreateProcess -- | 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 launching -- processes that require interaction over the standard file streams. -- -- 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 -- | readCreateProcess works exactly like readProcess -- except that it lets you pass CreateProcess giving better -- flexibility. -- --
--   > readCreateProcess ((shell "pwd") { cwd = Just "/etc/" }) ""
--   "/etc\n"
--   
-- -- Note that Handles provided for std_in or -- std_out via the CreateProcess record will be ignored. readCreateProcess :: CreateProcess -> String -> IO String -- | Construct a CreateProcess record for passing to -- createProcess, representing a raw command with arguments. -- -- See RawCommand for precise semantics of the specified -- FilePath. proc :: FilePath -> [String] -> CreateProcess -- | Returns the PID (process ID) of a subprocess. -- -- Nothing is returned if the handle was already closed. Otherwise -- a PID is returned that remains valid as long as the handle is open. -- The operating system may reuse the PID as soon as the last handle to -- the process is closed. getPid :: ProcessHandle -> IO (Maybe Pid) -- | Returns the PID (process ID) of the current process. On POSIX systems, -- this calls getProcessID from System.Posix.Process in the -- unix package. On Windows, this calls -- getCurrentProcessId from System.Win32.Process in the -- Win32 package. getCurrentPid :: IO Pid -- | This is the most general way to spawn an external process. The process -- can be a command line to be executed by a shell or a raw command with -- a list of arguments. The stdin, stdout, and stderr streams of the new -- process may individually be attached to new pipes, to existing -- Handles, or just inherited from the parent (the default.) -- -- The details of how to create the process are passed in the -- CreateProcess record. To make it easier to construct a -- CreateProcess, the functions proc and shell are -- supplied that fill in the fields with default values which can be -- overriden as needed. -- -- createProcess returns (mb_stdin_hdl, -- mb_stdout_hdl, mb_stderr_hdl, ph), where -- -- -- -- Similarly for mb_stdout_hdl and -- mb_stderr_hdl. -- -- For example, to execute a simple ls command: -- --
--   r <- createProcess (proc "ls" [])
--   
-- -- To create a pipe from which to read the output of ls: -- --
--   (_, Just hout, _, _) <-
--       createProcess (proc "ls" []){ std_out = CreatePipe }
--   
-- -- To also set the directory in which to run ls: -- --
--   (_, Just hout, _, _) <-
--       createProcess (proc "ls" []){ cwd = Just "/home/bob",
--                                     std_out = CreatePipe }
--   
-- -- Note that Handles provided for std_in, -- std_out, or std_err via the UseHandle -- constructor will be closed by calling this function. This is not -- always the desired behavior. In cases where you would like to leave -- the Handle open after spawning the child process, please use -- createProcess_ instead. All created Handles are -- initially in text mode; if you need them to be in binary mode then use -- hSetBinaryMode. -- -- ph contains a handle to the running process. On -- Windows use_process_jobs can be set in CreateProcess in order -- to create a Win32 Job object to monitor a process tree's progress. If -- it is set then that job is also returned inside ph. -- ph can be used to kill all running sub-processes. This -- feature has been available since 1.5.0.0. createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -- | Cleans up the process. -- -- This function is meant to be invoked from any application level -- cleanup handler. It terminates the process, and closes any -- CreatePipe handles. cleanupProcess :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> IO () -- | 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. 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. callCommand :: String -> 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 () -- | This function is almost identical to createProcess. The only -- differences are: -- -- -- -- This function has been available from the -- System.Process.Internals module for some time, and is part of -- the System.Process module since version 1.2.1.0. createProcess_ :: String -> CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -- | Create a pipe for interprocess communication and return a -- (readEnd, writeEnd) FD pair. createPipeFd :: IO (FD, FD) -- | Create a pipe for interprocess communication and return a -- (readEnd, writeEnd) Handle pair. createPipe :: IO (Handle, Handle) 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 -- | Close the stream's file descriptor without passing a Handle. On POSIX -- systems this may lead to strange behavior in the child process because -- attempting to read or write after the file has been closed throws an -- error. This should only be used with child processes that don't use -- the file descriptor at all. If you wish to ignore the child process's -- output you should either create a pipe and drain it manually or pass a -- Handle that writes to /dev/null. NoStream :: StdStream -- | A handle to a process, which can be used to wait for termination of -- the process using waitForProcess. -- -- None of the process-creation functions in this library wait for -- termination: they all return a ProcessHandle which may be used -- to wait for the process later. -- -- On Windows a second wait method can be used to block for event -- completion. This requires two handles. A process job handle and a -- events handle to monitor. data ProcessHandle data CreateProcess 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 readCreateProcessWithExitCode :: Exception e' => CreateProcess -> String -> ExitcodeT (ExceptT e' IO) (String, String) (String, String) readProcessWithExitCode :: Exception e' => FilePath -> [String] -> String -> ExitcodeT (ExceptT e' IO) (String, String) (String, String) waitForProcess :: Exception e' => ProcessHandle -> ExitcodeT (ExceptT e' IO) () () getProcessExitCode :: Exception e' => ProcessHandle -> ExitcodeT (ExceptT e' IO) (Maybe ()) (Maybe ()) getProcessExitCodeBool :: Exception e' => ProcessHandle -> ExitcodeT (ExceptT e' IO) Bool Bool module Control.Process.ProcessHandle class HasProcessHandle a processHandle :: HasProcessHandle a => Lens' a ProcessHandle class AsProcessHandle a _ProcessHandle :: AsProcessHandle a => Prism' a ProcessHandle instance Control.Process.ProcessHandle.AsProcessHandle System.Process.Common.ProcessHandle instance Control.Process.ProcessHandle.HasProcessHandle System.Process.Common.ProcessHandle module Control.Process.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 -- | Close the stream's file descriptor without passing a Handle. On POSIX -- systems this may lead to strange behavior in the child process because -- attempting to read or write after the file has been closed throws an -- error. This should only be used with child processes that don't use -- the file descriptor at all. If you wish to ignore the child process's -- output you should either create a pipe and drain it manually or pass a -- Handle that writes to /dev/null. NoStream :: StdStream class AsStdStream a _StdStream :: AsStdStream a => Prism' a StdStream _Inherit :: AsStdStream a => Prism' a () _CreatePipe :: AsStdStream a => Prism' a () _NoStream :: AsStdStream a => Prism' a () class HasStdStream a stdStream :: HasStdStream a => Lens' a StdStream instance Control.Process.StdStream.HasStdStream System.Process.Common.StdStream instance Control.Process.StdStream.AsStdStream System.Process.Common.StdStream module Control.Process.UserID class HasUserID a userID :: HasUserID a => Lens' a UserID userIDWord32 :: HasUserID a => Lens' a Word32 class AsUserID a _UserID :: AsUserID a => Prism' a UserID _UserIDWord32 :: AsUserID a => Prism' a Word32 instance Control.Process.UserID.AsUserID System.Posix.Types.UserID instance Control.Process.UserID.HasUserID System.Posix.Types.UserID module Control.Process.CreateProcess class HasCreateProcess a create_process :: HasCreateProcess a => Lens' a CreateProcess child_group :: HasCreateProcess a => Lens' a (Maybe GroupID) child_user :: HasCreateProcess a => Lens' a (Maybe UserID) close_fds :: HasCreateProcess a => Lens' a Bool create_group :: HasCreateProcess a => Lens' a Bool create_new_console :: HasCreateProcess a => Lens' a Bool cwd :: HasCreateProcess a => Lens' a (Maybe FilePath) delegate_ctlc :: HasCreateProcess a => Lens' a Bool detach_console :: HasCreateProcess a => Lens' a Bool env :: HasCreateProcess a => Lens' a (Maybe [(String, String)]) new_session :: HasCreateProcess a => Lens' a Bool std_err :: HasCreateProcess a => Lens' a StdStream std_in :: HasCreateProcess a => Lens' a StdStream std_out :: HasCreateProcess a => Lens' a StdStream use_process_jobs :: HasCreateProcess a => Lens' a Bool cwd' :: HasCreateProcess a => Traversal' a FilePath envList :: HasCreateProcess a => Traversal' a [(String, String)] envElement :: HasCreateProcess a => Traversal' a (String, String) envElementKey :: HasCreateProcess a => Traversal' a String envElementValue :: HasCreateProcess a => Traversal' a String close_fds' :: HasCreateProcess a => Traversal' a () create_group' :: HasCreateProcess a => Traversal' a () delegate_ctlc' :: HasCreateProcess a => Traversal' a () detach_console' :: HasCreateProcess a => Traversal' a () create_new_console' :: HasCreateProcess a => Traversal' a () new_session' :: HasCreateProcess a => Traversal' a () child_group' :: HasCreateProcess a => Traversal' a GroupID child_user' :: HasCreateProcess a => Traversal' a UserID child_user'' :: HasCreateProcess a => Traversal' a Word32 use_process_jobs' :: HasCreateProcess a => Traversal' a () class AsCreateProcess a _CreateProcess :: AsCreateProcess a => Prism' a CreateProcess streams :: Traversal' CreateProcess StdStream streams1 :: Traversal1' CreateProcess StdStream instance Control.Process.CreateProcess.AsCreateProcess System.Process.Common.CreateProcess instance Control.Process.CreateProcess.HasCreateProcess System.Process.Common.CreateProcess module Control.Process