Unixutils-1.22: A crude interface between Haskell and Unix-like operating systemsSource codeContentsIndex
System.Unix.Process
Contents
Strict process running
Lazy process running
Process killing
Description
functions for killing processes, running processes, etc
Synopsis
simpleProcess :: FilePath -> [String] -> IO (String, String, ExitCode)
processResult :: FilePath -> [String] -> IO (Either Int (String, String))
processOutput :: FilePath -> [String] -> IO (Either Int String)
simpleCommand :: String -> IO (String, String, ExitCode)
commandResult :: String -> IO (Either Int (String, String))
commandOutput :: String -> IO (Either Int String)
type Process = (Handle, Handle, Handle, ProcessHandle)
data Output
= Stdout ByteString
| Stderr ByteString
| Result ExitCode
lazyRun :: ByteString -> Process -> IO [Output]
lazyCommand :: String -> ByteString -> IO [Output]
lazyProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> ByteString -> IO [Output]
stdoutOnly :: [Output] -> ByteString
stderrOnly :: [Output] -> ByteString
outputOnly :: [Output] -> ByteString
checkResult :: (Int -> a) -> a -> [Output] -> a
discardStdout :: [Output] -> [Output]
discardStderr :: [Output] -> [Output]
discardOutput :: [Output] -> [Output]
mergeToStderr :: [Output] -> [Output]
mergeToStdout :: [Output] -> [Output]
collectStdout :: [Output] -> (ByteString, [Output])
collectStderr :: [Output] -> (ByteString, [Output])
collectOutput :: [Output] -> (ByteString, ByteString, [ExitCode])
collectOutputUnpacked :: [Output] -> (String, String, [ExitCode])
data ExitCode
= ExitSuccess
| ExitFailure Int
exitCodeOnly :: [Output] -> [ExitCode]
hPutNonBlocking :: Handle -> ByteString -> IO Int64
killByCwd :: FilePath -> IO [(String, Maybe String)]
Strict process running
simpleProcess :: FilePath -> [String] -> IO (String, String, ExitCode)Source

simpleProcess - run a process returning (stdout, stderr, exitcode)

Warning - stdout and stderr will be read strictly so that we do not deadlock when trying to check the exitcode. Do not try doing something like, simpleProcess ["yes"]

NOTE: this may still dead-lock because we first strictly read outStr and then errStr. Perhaps we should use forkIO or something?

processResult :: FilePath -> [String] -> IO (Either Int (String, String))Source
processOutput :: FilePath -> [String] -> IO (Either Int String)Source
simpleCommand :: String -> IO (String, String, ExitCode)Source
commandResult :: String -> IO (Either Int (String, String))Source
commandOutput :: String -> IO (Either Int String)Source
Lazy process running
type Process = (Handle, Handle, Handle, ProcessHandle)Source
This is the type returned by runInteractiveProcess et. al.
data Output Source
The process returns a list of objects of type Output. There will be one Result object at the end of the list (if the list has an end.)
Constructors
Stdout ByteString
Stderr ByteString
Result ExitCode
lazyRun :: ByteString -> Process -> IO [Output]Source
Take the tuple like that returned by runInteractiveProcess, create a process, send the list of inputs to its stdin and return the lazy list of Output objects.
lazyCommand :: String -> ByteString -> IO [Output]Source

Current verbosity level.

Create a process with runInteractiveCommand and run it with lazyRun.

lazyProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> ByteString -> IO [Output]Source
Create a process with runInteractiveProcess and run it with lazyRun.
stdoutOnly :: [Output] -> ByteStringSource
Filter everything except stdout from the output list.
stderrOnly :: [Output] -> ByteStringSource
Filter everything except stderr from the output list.
outputOnly :: [Output] -> ByteStringSource
Filter the exit codes output list and merge the two output streams in the order they appear.
checkResult :: (Int -> a) -> a -> [Output] -> aSource
discardStdout :: [Output] -> [Output]Source
discardStderr :: [Output] -> [Output]Source
discardOutput :: [Output] -> [Output]Source
mergeToStderr :: [Output] -> [Output]Source
Turn all the Stdout text into Stderr, preserving the order.
mergeToStdout :: [Output] -> [Output]Source
Turn all the Stderr text into Stdout, preserving the order.
collectStdout :: [Output] -> (ByteString, [Output])Source
Split out and concatenate Stdout
collectStderr :: [Output] -> (ByteString, [Output])Source
Split out and concatenate Stderr
collectOutput :: [Output] -> (ByteString, ByteString, [ExitCode])Source
Split out and concatenate both Stdout and Stderr, leaving only the exit code.
collectOutputUnpacked :: [Output] -> (String, String, [ExitCode])Source
Collect all output, unpack and concatenate.
data ExitCode Source
Constructors
ExitSuccessindicates successful termination;
ExitFailure Intindicates program failure with an exit code. The exact interpretation of the code is operating-system dependent. In particular, some values may be prohibited (e.g. 0 on a POSIX-compliant system).
exitCodeOnly :: [Output] -> [ExitCode]Source
Filter everything except the exit code from the output list.
hPutNonBlocking :: Handle -> ByteString -> IO Int64Source
This belongs in Data.ByteString. See ticket 1070, http://hackage.haskell.org/trac/ghc/ticket/1070.
Process killing
killByCwd :: FilePath -> IO [(String, Maybe String)]Source
Kill the processes whose working directory is in or under the given directory.
Produced by Haddock version 2.6.1