Unixutils-1.45: A crude interface between Haskell and Unix-like operating systems

System.Unix.Process

Contents

Description

functions for killing processes, running processes, etc

Synopsis

Lazy process running

type Process = (Handle, Handle, Handle, ProcessHandle)Source

This is the type returned by runInteractiveProcess et. al.

data Output Source

The lazyCommand, lazyProcess and lazyRun functions each return a list of Output. There will generally be one Result value at or near the end of the list (if the list has an end.)

Instances

lazyRun :: MonadIO m => ByteString -> Process -> m OutputsSource

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 :: MonadIO m => String -> ByteString -> m OutputsSource

Create a process with runInteractiveCommand and run it with lazyRun.

lazyProcess :: MonadIO m => FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> ByteString -> m OutputsSource

Create a process with runInteractiveProcess and run it with lazyRun.

stdoutOnly :: Outputs -> ByteStringSource

Filter everything except stdout from the output list.

stderrOnly :: Outputs -> ByteStringSource

Filter everything except stderr from the output list.

outputOnly :: Outputs -> ByteStringSource

Filter the exit codes output list and merge the two output streams in the order they appear.

checkResult :: (Int -> a) -> a -> Outputs -> aSource

discardStdout :: Outputs -> OutputsSource

discardStderr :: Outputs -> OutputsSource

discardOutput :: Outputs -> OutputsSource

mergeToStderr :: Outputs -> OutputsSource

Turn all the Stdout text into Stderr, preserving the order.

mergeToStdout :: Outputs -> OutputsSource

Turn all the Stderr text into Stdout, preserving the order.

collectStdout :: Outputs -> (ByteString, Outputs)Source

Split out and concatenate Stdout

collectStderr :: Outputs -> (ByteString, Outputs)Source

Split out and concatenate Stderr

collectOutput :: Outputs -> (ByteString, ByteString, ExitCode)Source

Split out and concatenate both Stdout and Stderr, leaving only the exit code.

collectOutputUnpacked :: Outputs -> (String, String, ExitCode)Source

Collect all output, unpack and concatenate.

collectResult :: Outputs -> (ExitCode, Outputs)Source

Partition the exit code from the outputs.

data ExitCode

Defines the exit codes that a program can return.

Constructors

ExitSuccess

indicates successful termination;

ExitFailure Int

indicates 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 :: Outputs -> ExitCodeSource

Filter everything except the exit code from the output list. See discussion in lazyRun of why we are confident that the list will contain exactly one Result. An opaque type to hold the Output list would lend additional safety here.

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.