-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Ergonomic process launching with extreme flexibility and speed -- -- procex is a library for launching unix processes, that DOES NOT wrap -- createProcess. It interfaces directly with vfork and execve, and -- closes fds efficiently using the new close_range Linux syscall (or -- close if not available). The syntax for launching processes is clean, -- concise, and flexible, mimicking sh. @package procex @version 0.3.3 -- | Contains FFI bindings to the C bits module Procex.Execve -- | The signature for execve and forkexecve. type Execve = ByteString " The full path to the executable." -> [ByteString] " The args to pass, including argv[0]." -> Maybe [ByteString] " The environment to pass. Will default to the current environment if 'Nothing' is passed." -> [Fd] " The fds to pass. All other fds will be closed. In the new process, the integral id for each fd will be set to the position the fd has in this list, e.g. the first element in this list will be stdin, and so on." -> IO (Maybe CPid) " The process id for the new process." -- | Replace the current process with a new process. execve :: Execve -- | Fork and execute a new process. forkexecve :: Execve -- | Defines Cmd, the core API of Procex. module Procex.Core -- | A command. You can execute this with run' or run. data Cmd -- | Make a Cmd from the path to an executable. Does not take PATH -- into account. See makeCmd for a version that provides some -- sensible defaults, like forwarding stdin, stdout, stderr. makeCmd' :: ByteString -> Cmd -- | Pass an argument to the command. passArg :: ByteString -> Cmd -> Cmd -- | Embeds the IO action inside the command, such that the IO action is -- executed when the command is executed. unIOCmd :: IO Cmd -> Cmd -- | Executes some code after launching the process. If launching the -- process fails, it will be provided with the exception it failed with. postCmd :: (Either SomeException (Async ProcessStatus) -> IO ()) -> Cmd -> Cmd -- | Runs the specified command asynchronously and returns the process -- status. run' :: Cmd -> IO (Async ProcessStatus) -- | Runs the specified commands and replaces the current process with it. -- This will not return unless an error occurs while executing the -- process. runReplace :: Cmd -> IO () -- | Bind a fd in the new process to a fd available now. If you try to bind -- an fd already bound, it will simply replace the older binding. passFd :: (Fd, Fd) -> Cmd -> Cmd -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is an fd which is a duplicate of the fd -- provided here. passArgFd :: Fd -> Cmd -> Cmd -- | Don't open a fd in the new process if it was going to be opened by -- passFd. Does not affect fds opened by passArgFd. passNoFd :: Fd -> Cmd -> Cmd instance GHC.Show.Show Procex.Core.Arg -- | This module wraps over the API in Procex.Core in a -- user-friendly way. module Procex.Process -- | A version of makeCmd' that resolves the path according to PATH -- and passes through stdin, stdout and stderr (unless overrided). makeCmd :: ByteString -> Cmd -- | Thrown when the return code of a command isn't 0. newtype CmdException CmdException :: ProcessStatus -> CmdException -- | Runs a command synchronously. See also run'. -- CmdException will be thrown if the command fails. run :: Cmd -> IO () -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is the reader end of a pipe which the -- command writes to through the specified fd. pipeArgIn :: Fd -> Cmd -> Cmd -> Cmd -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is the writer end of a pipe which the -- command reads from through the specified fd. pipeArgOut :: Fd -> Cmd -> Cmd -> Cmd -- | Pipes from the handle to the fd. pipeHIn :: Fd -> (Async ProcessStatus -> Handle -> IO ()) -> Cmd -> Cmd -- | Pipes from the fd to the handle. pipeHOut :: Fd -> (Async ProcessStatus -> Handle -> IO ()) -> Cmd -> Cmd -- | Pipes from the first command to the second command pipeIn :: Fd -> Fd -> Cmd -> Cmd -> Cmd -- | Pipes from the second command to the first command pipeOut :: Fd -> Fd -> Cmd -> Cmd -> Cmd -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is the reader end of a pipe where the writer -- end is passed to a Haskell function. pipeArgHIn :: (Async ProcessStatus -> Handle -> IO ()) -> Cmd -> Cmd -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is the writer end of a pipe where the reader -- end is passed to a Haskell function. pipeArgHOut :: (Async ProcessStatus -> Handle -> IO ()) -> Cmd -> Cmd -- | Captures the outputs to the specified fds. captureFdsAsHandles :: [Fd] -> Cmd -> IO (Async ProcessStatus, [Handle]) -- | Wait on a process status and raise CmdException if it is a -- non-zero exit code. waitCmd :: Async ProcessStatus -> IO () instance GHC.Show.Show Procex.Process.CmdException instance GHC.Exception.Type.Exception Procex.Process.CmdException -- | This module defines functions and type classes for making the syntax -- more succint. module Procex.Quick -- | Pipe from the right command's stderr to the left command. Returns the -- left command modified. ( Cmd -> Cmd -> a infixr 1 Cmd -> b -> a infix 1 <<< -- | Pipe from the right command to the left command. Returns the left -- command modified. (<|) :: QuickCmd a => Cmd -> Cmd -> a infixr 1 <| -- | Pipe from the left command's stderr to the right command. Returns the -- left command modified. (|!>) :: QuickCmd a => Cmd -> Cmd -> a infixr 1 |!> -- | Pipe from the left command to the right command. Returns the left -- command modified. (|>) :: QuickCmd a => Cmd -> Cmd -> a infixr 1 |> -- | captureFd for stdout. capture :: Cmd -> IO ByteString -- | captureFdNoThrow for stdout. captureNoThrow :: Cmd -> IO ByteString -- | captureFdLazy for stdout. captureLazy :: Cmd -> IO ByteString -- | captureFdLazyNoThrow for stdout. captureLazyNoThrow :: Cmd -> IO ByteString -- | captureFd for stderr. captureErr :: Cmd -> IO ByteString -- | captureFdNoThrow for stderr. captureErrNoThrow :: Cmd -> IO ByteString -- | captureFdLazy for stderr.. captureErrLazy :: Cmd -> IO ByteString -- | captureFdLazyNoThrow for stderr. captureErrLazyNoThrow :: Cmd -> IO ByteString -- | Capture the output of the fd of the command strictly, err if the -- command exits with a non-zero exit code. captureFd :: Fd -> Cmd -> IO ByteString -- | Capture the output of the fd of the command strictly. Ignores process -- exit code. captureFdNoThrow :: Fd -> Cmd -> IO ByteString -- | Capture the output of the fd of the command lazily. If the process -- exits with a non-zero exit code, reading from the bytestring will -- throw CmdException. Garbage collection will close the pipe. captureFdLazy :: Fd -> Cmd -> IO ByteString -- | Capture the output of the fd of the command lazily. Ignores process -- exit code. Garbage collection will close the pipe. captureFdLazyNoThrow :: Fd -> Cmd -> IO ByteString -- | Pass an argument of the form /proc/self/fd/<n> to the -- process, where n is the reader end of a pipe which the passed -- string is written to. pipeArgStrIn :: ToByteString b => b -> Cmd -> Cmd -- |
-- >>> mq "cat" "/dev/null" (pipeArgIn 1 $ mq "cat" "/dev/null") <<< "somestr" ---- -- The first argument is the path, and the subsequent arguments are -- QuickCmdArg. At the end you will either have an IO () -- (synchronous execution) or Cmd (which you can further use). mq :: (QuickCmd a, ToByteString b) => b -> a -- | A helper class to allow lightweight syntax for executing commands class QuickCmd a quickCmd :: QuickCmd a => Cmd -> a -- | If a type implements this, you can pass it to mq. class QuickCmdArg a quickCmdArg :: QuickCmdArg a => a -> Cmd -> Cmd -- | A helper class to convert to bytestrings with UTF-8 encoding class ToByteString a toByteString :: ToByteString a => a -> ByteString instance (Procex.Quick.QuickCmdArg a, Procex.Quick.QuickCmd b) => Procex.Quick.QuickCmd (a -> b) instance (a GHC.Types.~ ()) => Procex.Quick.QuickCmd (GHC.Types.IO a) instance Procex.Quick.QuickCmd Procex.Core.Cmd instance Procex.Quick.QuickCmdArg GHC.Base.String instance Procex.Quick.QuickCmdArg [GHC.Base.String] instance Procex.Quick.QuickCmdArg [Data.ByteString.Lazy.Internal.ByteString] instance Procex.Quick.QuickCmdArg [Procex.Core.Cmd -> Procex.Core.Cmd] instance (a GHC.Types.~ System.Posix.Types.Fd, b GHC.Types.~ Procex.Core.Cmd) => Procex.Quick.QuickCmdArg [(a, (GHC.IO.Handle.Types.Handle -> GHC.Types.IO b) -> GHC.Types.IO b)] instance (a GHC.Types.~ System.Posix.Types.Fd) => Procex.Quick.QuickCmdArg [(a, GHC.Types.IO GHC.IO.Handle.Types.Handle)] instance (a GHC.Types.~ System.Posix.Types.Fd) => Procex.Quick.QuickCmdArg [(a, GHC.IO.Handle.Types.Handle)] instance Procex.Quick.QuickCmdArg Data.ByteString.Lazy.Internal.ByteString instance (a GHC.Types.~ System.Posix.Types.Fd, b GHC.Types.~ Procex.Core.Cmd) => Procex.Quick.QuickCmdArg (a, (GHC.IO.Handle.Types.Handle -> GHC.Types.IO b) -> GHC.Types.IO b) instance (a GHC.Types.~ System.Posix.Types.Fd) => Procex.Quick.QuickCmdArg (a, GHC.Types.IO GHC.IO.Handle.Types.Handle) instance (a GHC.Types.~ System.Posix.Types.Fd) => Procex.Quick.QuickCmdArg (a, GHC.IO.Handle.Types.Handle) instance Procex.Quick.QuickCmdArg (Procex.Core.Cmd -> Procex.Core.Cmd) instance (a GHC.Types.~ GHC.Types.Char) => Procex.Quick.ToByteString [a] instance Procex.Quick.ToByteString Data.ByteString.Lazy.Internal.ByteString instance Procex.Quick.ToByteString Data.ByteString.Internal.ByteString -- | You'll likely import this if you're using Procex. module Procex.Prelude -- | You'll likely want to import this if you're using Procex for your -- shell, though you'll likely want to customize your -- promptFunction some time. module Procex.Shell -- | For some ungodly reason, cd-ing inside ghci won't change the cwd of -- ghci itself, so completion, etc. will always happen from the directory -- you started ghci in. This is a quick hack to work around this by also -- running changeWorkingDirectory "above" the shell. -- -- Do `:set prompt-function promptFunction` in GHCi promptFunction :: [String] -> Int -> IO String -- | You need to run this if you want stdin to work properly inside ghci. initInteractive :: IO () -- | This goes hand-in-hand with promptFunction. It is a standard -- changeWorkingDirectory, but it sets PWD in the -- environment too. cd :: String -> IO () -- | This module contains an instance for labels, that causes labels to be -- interpreted as strings, with _ replaced with -. -- -- It is useful for shells, since it's easier to type arguments with -- labels. -- -- NB: _ is replaced with -. module Procex.Shell.Labels instance (a GHC.Types.~ GHC.Base.String, GHC.TypeLits.KnownSymbol l) => GHC.OverloadedLabels.IsLabel l a