Safe Haskell | Safe-Infered |
---|
Support for running external tools. Written mainly for GHCi but with | support for others in mind.
- data ToolOutput
- toolline :: ToolOutput -> String
- data ToolCommand = ToolCommand String String (Iteratee ToolOutput IO ())
- data ToolState = ToolState {}
- toolProcess :: ToolState -> IO ProcessHandle
- newToolState :: IO ToolState
- runTool :: MonadIO m => FilePath -> [String] -> Maybe FilePath -> IO (Enumerator ToolOutput m b, ProcessHandle)
- runTool' :: FilePath -> [String] -> Maybe FilePath -> IO ([ToolOutput], ProcessHandle)
- runInteractiveTool :: ToolState -> CommandLineReader -> FilePath -> [String] -> IO ()
- newGhci :: [String] -> [String] -> Iteratee ToolOutput IO () -> IO ToolState
- newGhci' :: [String] -> Iteratee ToolOutput IO () -> IO ToolState
- executeCommand :: ToolState -> String -> String -> Iteratee ToolOutput IO () -> IO ()
- executeGhciCommand :: ToolState -> String -> Iteratee ToolOutput IO () -> IO ()
- quoteArg :: String -> String
- escapeQuotes :: String -> String
- runCommand :: String -> IO ProcessHandle
- waitForProcess :: ProcessHandle -> IO ExitCode
- interruptProcessGroupOf :: ProcessHandle -> IO ()
- data ProcessHandle
- getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)
- runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)
- runProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> Maybe Handle -> Maybe Handle -> Maybe Handle -> IO ProcessHandle
Documentation
data ToolOutput Source
toolline :: ToolOutput -> StringSource
runTool :: MonadIO m => FilePath -> [String] -> Maybe FilePath -> IO (Enumerator ToolOutput m b, ProcessHandle)Source
runTool' :: FilePath -> [String] -> Maybe FilePath -> IO ([ToolOutput], ProcessHandle)Source
executeGhciCommand :: ToolState -> String -> Iteratee ToolOutput IO () -> IO ()Source
escapeQuotes :: String -> StringSource
runCommand :: String -> IO ProcessHandle
Runs a command using the shell.
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
.
:: ProcessHandle | A process in the process group |
-> IO () |
Sends an interrupt signal to the process group of the given process.
On Unix systems, it sends the group the SIGINT signal.
On Windows systems, it generates a CTRL_BREAK_EVENT and will only work for
processes created using createProcess
and setting the create_group
flag
data ProcessHandle
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
is returned where Just
ee
is the exit code of the process.
:: 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 Handle
s 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)
The Handle
s are initially in binary mode; if you need them to be
in text mode then use hSetBinaryMode
.
:: 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 |
-> Maybe Handle | Handle to use for |
-> Maybe Handle | Handle to use for |
-> IO ProcessHandle |
Runs a raw command, optionally specifying Handle
s from which to
take the stdin
, stdout
and stderr
channels for the new
process (otherwise these handles are inherited from the current
process).
Any Handle
s passed to runProcess
are placed immediately in the
closed state.
Note: consider using the more general createProcess
instead of
runProcess
.