|
System.Process | Portability | portable | Stability | experimental | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
Operations for creating and interacting with sub-processes.
For a simpler, but less powerful, interface, see the System.Cmd module.
|
|
Synopsis |
|
|
|
|
Running sub-processes
|
|
data ProcessHandle |
|
|
runCommand :: String -> IO ProcessHandle |
Runs a command using the shell.
|
|
runProcess |
:: FilePath | Filename of the executable
| -> [String] | Arguments to pass to the executable
| -> Maybe FilePath | Optional path to the working directory
| -> Maybe [(String, String)] | Optional environment (otherwise inherit)
| -> Maybe Handle | Handle to use for stdin
| -> Maybe Handle | Handle to use for stdout
| -> Maybe Handle | Handle 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 |
:: FilePath | Filename of the executable
| -> [String] | Arguments to pass to the executable
| -> Maybe FilePath | Optional 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 |