process-conduit-1.0.0.0: Conduits for processes

Safe Haskell | None

Data.Conduit.Process

Contents

- Run process
- Run shell command
- Convenience re-exports

Synopsis

- sourceProcess :: MonadResource m => CreateProcess -> Producer m ByteString
- conduitProcess :: MonadResource m => CreateProcess -> Conduit ByteString m ByteString
- sourceCmd :: MonadResource m => String -> Producer m ByteString
- conduitCmd :: MonadResource m => String -> Conduit ByteString m ByteString
- shell :: String -> CreateProcess
- proc :: FilePath -> [String] -> CreateProcess
- data CreateProcess = CreateProcess {
  - cmdspec :: CmdSpec
  - cwd :: Maybe FilePath
  - env :: Maybe [(String, String)]
  - std_in :: StdStream
  - std_out :: StdStream
  - std_err :: StdStream
  - close_fds :: Bool
  - create_group :: Bool
  }
- data CmdSpec
  - = ShellCommand String
  - | RawCommand FilePath [String]
- data StdStream
  - = Inherit
  - | UseHandle Handle
  - | CreatePipe
- data ProcessHandle

# Run process

sourceProcess :: MonadResource m => CreateProcess -> Producer m ByteString Source

Source of process

conduitProcess :: MonadResource m => CreateProcess -> Conduit ByteString m ByteString Source

Conduit of process

# Run shell command

sourceCmd :: MonadResource m => String -> Producer m ByteString Source

Source of shell command

conduitCmd :: MonadResource m => String -> Conduit ByteString m ByteString Source

Conduit of shell command

# Convenience re-exports

shell :: String -> CreateProcess

Construct a `CreateProcess` record for passing to `createProcess`, representing a command to be passed to the shell.

proc :: FilePath -> [String] -> CreateProcess

Construct a `CreateProcess` record for passing to `createProcess`, representing a raw command with arguments.

The `FilePath` names the executable, and is interpreted according to the platform's standard policy for searching for executables. Specifically:

- on Unix systems the `execvp` semantics is used, where if the filename does not contain a slash (`/`) then the `PATH` environment variable is searched for the executable.
- on Windows systems the Win32 `CreateProcess` semantics is used. Briefly: if the filename does not contain a path, then the directory containing the parent executable is searched, followed by the current directory, then some some standard locations, and finally the current `PATH`. An `.exe` extension is added if the filename does not already have an extension. For full details see the documentation for the Windows `SearchPath` API.

data CreateProcess

Constructors

CreateProcess |

Fields

cmdspec :: CmdSpec

  Executable & arguments, or shell command

cwd :: Maybe FilePath

  Optional path to the working directory for the new process

env :: Maybe [(String, String)]

  Optional environment (otherwise inherit from the current process)

std_in :: StdStream

  How to determine stdin

std_out :: StdStream

  How to determine stdout

std_err :: StdStream

  How to determine stderr

close_fds :: Bool

  Close all file descriptors except stdin, stdout and stderr in the new process (on Windows, only works if std_in, std_out, and std_err are all Inherit)

create_group :: Bool

  Create a new process group

data CmdSpec

Constructors

ShellCommand String | a command line to execute using the shell
RawCommand FilePath [String] | the filename of an executable with a list of arguments. see `proc` for the precise interpretation of the `FilePath` field.

data StdStream

Constructors

Inherit | Inherit Handle from parent
UseHandle Handle | Use the supplied Handle
CreatePipe | Create a new pipe. The returned `Handle` will use the default encoding and newline translation mode (just like `Handle`s created by `openFile`).

data ProcessHandle