|
System.Process | Portability | portable | Stability | experimental | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
Operations for creating and interacting with sub-processes.
|
|
Synopsis |
|
|
|
|
Running sub-processes
|
|
data ProcessHandle |
|
|
runCommand :: String -> IO ProcessHandle |
Runs a command using the shell.
|
|
runProcess |
|
|
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 |