Safe Haskell | Safe-Inferred |
---|
Utilities to deal with processes.
Synopsis
- readProcessWithExitCode :: Maybe [(String.String, String.String)] -> IO.FilePath -> [String.String] -> ByteString.ByteString -> IO.IO (Exit.ExitCode, ByteString.ByteString, ByteString.ByteString)
- supervised :: Process.CreateProcess -> IO.IO ()
- waitAndLog :: Process.CreateProcess -> Maybe Process.ProcessHandle -> IO.IO ()
- waitError :: Process.CreateProcess -> Maybe Process.ProcessHandle -> IO.IO (Maybe Text)
- call :: IO.FilePath -> [String.String] -> IO.IO ()
- create :: Process.CreateProcess -> IO.IO (Maybe IO.Handle, Maybe IO.Handle, Maybe IO.Handle, Maybe Process.ProcessHandle)
- data TalkOut
- data TalkIn
- data Exit
- conversation :: IO.FilePath -> [String.String] -> Maybe [(String.String, String.String)] -> Chan.Chan TalkIn -> (Chan.Chan TalkOut -> IO.IO a) -> IO.IO a
- multipleOutput :: [(IO.FilePath, [String.String])] -> (Chan.Chan ((IO.FilePath, [String.String]), TalkOut) -> IO.IO a) -> IO.IO a
- conversationWith :: IO.FilePath -> [String.String] -> Maybe [(String.String, String.String)] -> IO.IO TalkIn -> (TalkOut -> IO.IO ()) -> IO.IO a -> IO.IO a
- binaryNotFound :: IO.IO a -> IO.IO (Maybe a)
- toUsec :: NominalDiffTime -> Int
- cmdOf :: Process.CreateProcess -> String.String
- binaryOf :: Process.CreateProcess -> IO.FilePath
- isAlive :: ProcessID -> IO.IO Bool
- commandName :: ProcessID -> IO.IO (Maybe String.String)
- exit :: Int -> IO.IO a
Documentation
readProcessWithExitCode :: Maybe [(String.String, String.String)] -> IO.FilePath -> [String.String] -> ByteString.ByteString -> IO.IO (Exit.ExitCode, ByteString.ByteString, ByteString.ByteString) Source #
Similar to Process.readProcessWithExitCode
but return ByteStrings
instead of String.
supervised :: Process.CreateProcess -> IO.IO () Source #
Start a subprocess, wait for it to complete, and kill it if this thread
is killed. This is like Async.withAsync
, except for a subprocess, and
it's hardcoded to wait for the subprocess.
TODO use Process.withCreateProcess?
TODO I think multipleOutput
makes this obsolete.
waitAndLog :: Process.CreateProcess -> Maybe Process.ProcessHandle -> IO.IO () Source #
Wait for the process (if it started) and log if it didn't exit successfully.
call :: IO.FilePath -> [String.String] -> IO.IO () Source #
Like Process.callProcess
, but log if the binary wasn't found or
failed.
create :: Process.CreateProcess -> IO.IO (Maybe IO.Handle, Maybe IO.Handle, Maybe IO.Handle, Maybe Process.ProcessHandle) Source #
Like Process.createProcess
, but return a Nothing instead of a pid if
the binary doesn't exist.
conversation
Stdout !Text | |
Stderr !Text | |
Exit !Exit | This always terminates the conversation, and effectively marks the channel closed. |
Instances
String.IsString TalkIn Source # | |
Defined in Util.Processes fromString :: String.String -> TalkIn # | |
Show TalkIn Source # | |
Eq TalkIn Source # | |
conversation :: IO.FilePath -> [String.String] -> Maybe [(String.String, String.String)] -> Chan.Chan TalkIn -> (Chan.Chan TalkOut -> IO.IO a) -> IO.IO a Source #
Have a conversation with a subprocess. This doesn't use ptys, so this will only work if the subprocess explicitly doesn't use block buffering.
multipleOutput :: [(IO.FilePath, [String.String])] -> (Chan.Chan ((IO.FilePath, [String.String]), TalkOut) -> IO.IO a) -> IO.IO a Source #
Get output from multiple subprocesses. They'll be killed when the action returns, if they haven't already exited.
conversationWith :: IO.FilePath -> [String.String] -> Maybe [(String.String, String.String)] -> IO.IO TalkIn -> (TalkOut -> IO.IO ()) -> IO.IO a -> IO.IO a Source #
binaryNotFound :: IO.IO a -> IO.IO (Maybe a) Source #
ghc 9.2 seems to have added a bug on darwin where binary not found is reported as illegal operation from a binary, and errno=0 from ghci.
toUsec :: NominalDiffTime -> Int Source #
util
commandName :: ProcessID -> IO.IO (Maybe String.String) Source #