process-1.0.0.0: Process librariesContentsIndex
System.Process
Portabilityportable
Stabilityexperimental
Maintainerlibraries@haskell.org
Contents
Running sub-processes
Process completion
Description

Operations for creating and interacting with sub-processes.

For a simpler, but less powerful, interface, see the System.Cmd module.

Synopsis
data ProcessHandle
runCommand :: String -> IO ProcessHandle
runProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> Maybe Handle -> Maybe Handle -> Maybe Handle -> IO ProcessHandle
runInteractiveCommand :: String -> IO (Handle, Handle, Handle, ProcessHandle)
runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)
waitForProcess :: ProcessHandle -> IO ExitCode
getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)
terminateProcess :: ProcessHandle -> IO ()
Running sub-processes
data ProcessHandle
runCommand :: String -> IO ProcessHandle
Runs a command using the shell.
runProcess
:: FilePathFilename of the executable
-> [String]Arguments to pass to the executable
-> Maybe FilePathOptional path to the working directory
-> Maybe [(String, String)]Optional environment (otherwise inherit)
-> Maybe HandleHandle to use for stdin
-> Maybe HandleHandle to use for stdout
-> Maybe HandleHandle to use for stderr
-> IO ProcessHandle

Runs a raw command, optionally specifying Handles from which to take the stdin, stdout and stderr channels for the new process (otherwise these handles are inherited from the current process).

Any Handles passed to runProcess are placed immediately in the closed state.

runInteractiveCommand :: String -> IO (Handle, Handle, Handle, ProcessHandle)
Runs a command using the shell, and returns Handles that may be used to communicate with the process via its stdin, stdout, and stderr respectively.
runInteractiveProcess
:: FilePathFilename of the executable
-> [String]Arguments to pass to the executable
-> Maybe FilePathOptional path to the working directory
-> Maybe [(String, String)]Optional environment (otherwise inherit)
-> IO (Handle, Handle, Handle, ProcessHandle)

Runs a raw command, and returns Handles that may be used to communicate with the process via its stdin, stdout and stderr respectively.

For example, to start a process and feed a string to its stdin:

   (inp,out,err,pid) <- runInteractiveProcess "..."
   forkIO (hPutStr inp str)
Process completion
waitForProcess :: ProcessHandle -> IO ExitCode

Waits for the specified process to terminate, and returns its exit code.

GHC Note: in order to call waitForProcess without blocking all the other threads in the system, you must compile the program with -threaded.

getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)
This is a non-blocking version of waitForProcess. If the process is still running, Nothing is returned. If the process has exited, then Just e is returned where e is the exit code of the process. Subsequent calls to getProcessExitStatus always return Just ExitSuccess, regardless of what the original exit code was.
terminateProcess :: ProcessHandle -> IO ()

Attempts to terminate the specified process. This function should not be used under normal circumstances - no guarantees are given regarding how cleanly the process is terminated. To check whether the process has indeed terminated, use getProcessExitCode.

On Unix systems, terminateProcess sends the process the SIGKILL signal. On Windows systems, the Win32 TerminateProcess function is called, passing an exit code of 1.

Produced by Haddock version 0.8