unliftio-0.2.13: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe Haskell | Safe
Language | Haskell2010

UnliftIO.Process

Contents

- Running sub-processes
  - Simpler functions for common tasks
  - Related utilities
- Process completion
- Interprocess communication

Description

Unlifted System.Process.

Since: 0.2.5.0

Synopsis

- 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
  - delegate_ctlc :: Bool
  - detach_console :: Bool
  - create_new_console :: Bool
  - new_session :: Bool
  - child_group :: Maybe GroupID
  - child_user :: Maybe UserID
  - use_process_jobs :: Bool
  }
- data CmdSpec
  - = ShellCommand String
  - | RawCommand FilePath [String]
- data StdStream
  - = Inherit
  - | UseHandle Handle
  - | CreatePipe
  - | NoStream
- data ProcessHandle
- createProcess :: MonadIO m => CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
- createProcess_ :: MonadIO m => String -> CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
- shell :: String -> CreateProcess
- proc :: FilePath -> [String] -> CreateProcess
- callProcess :: MonadIO m => FilePath -> [String] -> m ()
- callCommand :: MonadIO m => String -> m ()
- spawnProcess :: MonadIO m => FilePath -> [String] -> m ProcessHandle
- spawnCommand :: MonadIO m => String -> m ProcessHandle
- readCreateProcess :: MonadIO m => CreateProcess -> String -> m String
- readProcess :: MonadIO m => FilePath -> [String] -> String -> m String
- readCreateProcessWithExitCode :: MonadIO m => CreateProcess -> String -> m (ExitCode, String, String)
- readProcessWithExitCode :: MonadIO m => FilePath -> [String] -> String -> m (ExitCode, String, String)
- withCreateProcess :: MonadUnliftIO m => CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> m a) -> m a
- showCommandForUser :: FilePath -> [String] -> String
- waitForProcess :: MonadIO m => ProcessHandle -> m ExitCode
- getProcessExitCode :: MonadIO m => ProcessHandle -> m (Maybe ExitCode)
- terminateProcess :: MonadIO m => ProcessHandle -> m ()
- interruptProcessGroupOf :: MonadIO m => ProcessHandle -> m ()
- createPipe :: MonadIO m => m (Handle, Handle)
- createPipeFd :: MonadIO m => m (FD, FD)

# Running sub-processes

data CreateProcess #

Constructors

CreateProcess |

Fields

- cmdspec :: CmdSpec
- cwd :: Maybe FilePath
- env :: Maybe [(String, String)]
- std_in :: StdStream
- std_out :: StdStream
- std_err :: StdStream
- close_fds :: Bool
- create_group :: Bool
- delegate_ctlc :: Bool
- detach_console :: Bool
- create_new_console :: Bool
- new_session :: Bool
- child_group :: Maybe GroupID
- child_user :: Maybe UserID
- use_process_jobs :: Bool

#### Instances

Instances details

Eq CreateProcess |
Instance details Defined in System.Process.Common Methods (==) :: CreateProcess -> CreateProcess -> Bool (/=) :: CreateProcess -> CreateProcess -> Bool
Show CreateProcess |
Instance details Defined in System.Process.Common Methods showsPrec :: Int -> CreateProcess -> ShowS show :: CreateProcess -> String showList :: [CreateProcess] -> ShowS

data CmdSpec #

Constructors

ShellCommand String |
RawCommand FilePath [String] |

#### Instances

Instances details

Eq CmdSpec |
Instance details Defined in System.Process.Common Methods (==) :: CmdSpec -> CmdSpec -> Bool (/=) :: CmdSpec -> CmdSpec -> Bool
Show CmdSpec |
Instance details Defined in System.Process.Common Methods showsPrec :: Int -> CmdSpec -> ShowS show :: CmdSpec -> String showList :: [CmdSpec] -> ShowS
IsString CmdSpec |
Instance details Defined in System.Process.Common Methods fromString :: String -> CmdSpec

data StdStream #

Constructors

Inherit |
UseHandle Handle |
CreatePipe |
NoStream |

#### Instances

Instances details

Eq StdStream |
Instance details Defined in System.Process.Common Methods (==) :: StdStream -> StdStream -> Bool (/=) :: StdStream -> StdStream -> Bool
Show StdStream |
Instance details Defined in System.Process.Common Methods showsPrec :: Int -> StdStream -> ShowS show :: StdStream -> String showList :: [StdStream] -> ShowS

data ProcessHandle #

createProcess :: MonadIO m => CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

Lifted `createProcess`.

Since: 0.2.5.0

createProcess_ :: MonadIO m => String -> CreateProcess -> m (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) Source #

Lifted `createProcess_`.

Since: 0.2.5.0

shell :: String -> CreateProcess #

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

## Simpler functions for common tasks

callProcess :: MonadIO m => FilePath -> [String] -> m () Source #

Lifted `callProcess`.

Since: 0.2.5.0

callCommand :: MonadIO m => String -> m () Source #

Lifted `callCommand`.

Since: 0.2.5.0

spawnProcess :: MonadIO m => FilePath -> [String] -> m ProcessHandle Source #

Lifted `spawnProcess`.

Since: 0.2.5.0

spawnCommand :: MonadIO m => String -> m ProcessHandle Source #

Lifted `spawnCommand`.

Since: 0.2.5.0

readCreateProcess :: MonadIO m => CreateProcess -> String -> m String Source #

Lifted `readCreateProcess`.

Since: 0.2.5.0

readProcess :: MonadIO m => FilePath -> [String] -> String -> m String Source #

Lifted `readProcess`.

Since: 0.2.5.0

readCreateProcessWithExitCode :: MonadIO m => CreateProcess -> String -> m (ExitCode, String, String) Source #

Lifted `readCreateProcessWithExitCode`.

Since: 0.2.5.0

readProcessWithExitCode :: MonadIO m => FilePath -> [String] -> String -> m (ExitCode, String, String) Source #

Lifted `readProcessWithExitCode`.

Since: 0.2.5.0

withCreateProcess :: MonadUnliftIO m => CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> m a) -> m a Source #

Unlifted `withCreateProcess`.

Since: 0.2.5.0

## Related utilities

showCommandForUser :: FilePath -> [String] -> String #

# Process completion

waitForProcess :: MonadIO m => ProcessHandle -> m ExitCode Source #

Lifted `waitForProcess`.

Since: 0.2.5.0

getProcessExitCode :: MonadIO m => ProcessHandle -> m (Maybe ExitCode) Source #

Lifted `getProcessExitCode`.

Since: 0.2.5.0

terminateProcess :: MonadIO m => ProcessHandle -> m () Source #

Lifted `terminateProcess`.

Since: 0.2.5.0

interruptProcessGroupOf :: MonadIO m => ProcessHandle -> m () Source #

Lifted `interruptProcessGroupOf`.

Since: 0.2.5.0

# Interprocess communication

createPipe :: MonadIO m => m (Handle, Handle) Source #

Lifted `createPipe`.

Since: 0.2.5.0

createPipeFd :: MonadIO m => m (FD, FD) Source #

Lifted `createPipeFd`.

Since: 0.2.5.0