-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Process libraries
gr
grThis package contains libraries for dealing with system processes.
gr
grThe typed-process package is a more recent take on a process API,
grwhich uses this package internally. It features better binary support,
greasier concurrency, and a more composable API. You can read more about
grit at <a>https://haskell-lang.org/library/typed-process</a>.
@package process
@version 1.6.3.0


-- | <b>Note:</b> This module exports internal implementation details that
grmay change anytime. If you want a more stable API, use
gr<a>System.Process</a> instead.
module System.Process.Internals
data ProcessHandle
ProcessHandle :: !(MVar ProcessHandle__) -> !Bool -> !(MVar ()) -> ProcessHandle
[phandle] :: ProcessHandle -> !(MVar ProcessHandle__)
[mb_delegate_ctlc] :: ProcessHandle -> !Bool
[waitpidLock] :: ProcessHandle -> !(MVar ())

-- | A handle to a process, which can be used to wait for termination of
grthe process using <a>waitForProcess</a>.
gr
grNone of the process-creation functions in this library wait for
grtermination: they all return a <a>ProcessHandle</a> which may be used
grto wait for the process later.
gr
grOn Windows a second wait method can be used to block for event
grcompletion. This requires two handles. A process job handle and a
grevents handle to monitor.
data ProcessHandle__
OpenHandle :: PHANDLE -> ProcessHandle__
OpenExtHandle :: PHANDLE -> PHANDLE -> PHANDLE -> ProcessHandle__
ClosedHandle :: ExitCode -> ProcessHandle__
type PHANDLE = CPid
closePHANDLE :: PHANDLE -> IO ()
mkProcessHandle :: PHANDLE -> Bool -> IO ProcessHandle
data CGid
type GroupID = CGid
type UserID = CUid
modifyProcessHandle :: ProcessHandle -> (ProcessHandle__ -> IO (ProcessHandle__, a)) -> IO a
withProcessHandle :: ProcessHandle -> (ProcessHandle__ -> IO a) -> IO a
data CreateProcess
CreateProcess :: CmdSpec -> Maybe FilePath -> Maybe [(String, String)] -> StdStream -> StdStream -> StdStream -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe GroupID -> Maybe UserID -> Bool -> CreateProcess

-- | Executable &amp; arguments, or shell command. If <a>cwd</a> is
gr<a>Nothing</a>, relative paths are resolved with respect to the
grcurrent working directory. If <a>cwd</a> is provided, it is
grimplementation-dependent whether relative paths are resolved with
grrespect to <a>cwd</a> or the current working directory, so absolute
grpaths should be used to ensure portability.
[cmdspec] :: CreateProcess -> CmdSpec

-- | Optional path to the working directory for the new process
[cwd] :: CreateProcess -> Maybe FilePath

-- | Optional environment (otherwise inherit from the current process)
[env] :: CreateProcess -> Maybe [(String, String)]

-- | How to determine stdin
[std_in] :: CreateProcess -> StdStream

-- | How to determine stdout
[std_out] :: CreateProcess -> StdStream

-- | How to determine stderr
[std_err] :: CreateProcess -> StdStream

-- | Close all file descriptors except stdin, stdout and stderr in the new
grprocess (on Windows, only works if std_in, std_out, and std_err are
grall Inherit)
[close_fds] :: CreateProcess -> Bool

-- | Create a new process group
[create_group] :: CreateProcess -> Bool

-- | Delegate control-C handling. Use this for interactive console
grprocesses to let them handle control-C themselves (see below for
grdetails).
gr
grOn Windows this has no effect.
[delegate_ctlc] :: CreateProcess -> Bool

-- | Use the windows DETACHED_PROCESS flag when creating the process; does
grnothing on other platforms.
[detach_console] :: CreateProcess -> Bool

-- | Use the windows CREATE_NEW_CONSOLE flag when creating the process;
grdoes nothing on other platforms.
gr
grDefault: <tt>False</tt>
[create_new_console] :: CreateProcess -> Bool

-- | Use posix setsid to start the new process in a new session; does
grnothing on other platforms.
[new_session] :: CreateProcess -> Bool

-- | Use posix setgid to set child process's group id; does nothing on
grother platforms.
gr
grDefault: <tt>Nothing</tt>
[child_group] :: CreateProcess -> Maybe GroupID

-- | Use posix setuid to set child process's user id; does nothing on other
grplatforms.
gr
grDefault: <tt>Nothing</tt>
[child_user] :: CreateProcess -> Maybe UserID

-- | On Windows systems this flag indicates that we should wait for the
grentire process tree to finish before unblocking. On POSIX systems this
grflag is ignored.
gr
grDefault: <tt>False</tt>
[use_process_jobs] :: CreateProcess -> Bool
data CmdSpec

-- | A command line to execute using the shell
ShellCommand :: String -> CmdSpec

-- | The name of an executable with a list of arguments
gr
grThe <a>FilePath</a> argument names the executable, and is interpreted
graccording to the platform's standard policy for searching for
grexecutables. Specifically:
gr
gr<ul>
gr<li>on Unix systems the <a>execvp(3)</a> semantics is used, where if
grthe executable filename does not contain a slash (<tt>/</tt>) then the
gr<tt>PATH</tt> environment variable is searched for the
grexecutable.</li>
gr<li>on Windows systems the Win32 <tt>CreateProcess</tt> semantics is
grused. Briefly: if the filename does not contain a path, then the
grdirectory containing the parent executable is searched, followed by
grthe current directory, then some standard locations, and finally the
grcurrent <tt>PATH</tt>. An <tt>.exe</tt> extension is added if the
grfilename does not already have an extension. For full details see the
gr<a>documentation</a> for the Windows <tt>SearchPath</tt> API.</li>
gr</ul>
RawCommand :: FilePath -> [String] -> CmdSpec
data StdStream

-- | Inherit Handle from parent
Inherit :: StdStream

-- | Use the supplied Handle
UseHandle :: Handle -> StdStream

-- | Create a new pipe. The returned <tt>Handle</tt> will use the default
grencoding and newline translation mode (just like <tt>Handle</tt>s
grcreated by <tt>openFile</tt>).
CreatePipe :: StdStream

-- | No stream handle will be passed
NoStream :: StdStream

-- | contains the handles returned by a call to createProcess_Internal
data ProcRetHandles
ProcRetHandles :: Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> ProcRetHandles
[hStdInput] :: ProcRetHandles -> Maybe Handle
[hStdOutput] :: ProcRetHandles -> Maybe Handle
[hStdError] :: ProcRetHandles -> Maybe Handle
[procHandle] :: ProcRetHandles -> ProcessHandle

-- | This function is almost identical to <a>createProcess</a>. The only
grdifferences are:
gr
gr<ul>
gr<li><a>Handle</a>s provided via <a>UseHandle</a> are not closed
grautomatically.</li>
gr<li>This function takes an extra <tt>String</tt> argument to be used
grin creating error messages.</li>
gr<li><a>use_process_jobs</a> can be set in CreateProcess since 1.5.0.0
grin order to create an I/O completion port to monitor a process tree's
grprogress on Windows.</li>
gr</ul>
gr
grThe function also returns two new handles: * an I/O Completion Port
grhandle on which events will be signaled. * a Job handle which can be
grused to kill all running processes.
gr
grOn POSIX platforms these two new handles will always be Nothing
gr
grThis function has been available from the
gr<a>System.Process.Internals</a> module for some time, and is part of
grthe <a>System.Process</a> module since version 1.2.1.0.
createProcess_ :: String -> CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)

-- | <i>Deprecated: Please do not use this anymore, use the ordinary
gr<a>createProcess</a>. If you need the SIGINT handling, use
grdelegate_ctlc = True (runGenProcess_ is now just an imperfectly
gremulated stub that probably duplicates or overrides your own signal
grhandling).</i>
runGenProcess_ :: String -> CreateProcess -> Maybe CLong -> Maybe CLong -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)

-- | Turn an existing file descriptor into a Handle. This is used by
grvarious external libraries to make Handles.
gr
grMakes a binary Handle. This is for historical reasons; it should
grprobably be a text Handle with the default encoding and newline
grtranslation instead.
fdToHandle :: FD -> IO Handle
startDelegateControlC :: IO ()
endDelegateControlC :: ExitCode -> IO ()
stopDelegateControlC :: IO ()
unwrapHandles :: ProcRetHandles -> (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
pPrPr_disableITimers :: IO ()
c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt
ignoreSignal :: CLong
defaultSignal :: CLong
withFilePathException :: FilePath -> IO a -> IO a
withCEnvironment :: [(String, String)] -> (Ptr CString -> IO a) -> IO a
translate :: String -> String

-- | Create a pipe for interprocess communication and return a
gr<tt>(readEnd, writeEnd)</tt> <a>Handle</a> pair.
createPipe :: IO (Handle, Handle)

-- | Create a pipe for interprocess communication and return a
gr<tt>(readEnd, writeEnd)</tt> <a>FD</a> pair.
createPipeFd :: IO (FD, FD)

-- | Sends an interrupt signal to the process group of the given process.
gr
grOn Unix systems, it sends the group the SIGINT signal.
gr
grOn Windows systems, it generates a CTRL_BREAK_EVENT and will only work
grfor processes created using <tt>createProcess</tt> and setting the
gr<a>create_group</a> flag
interruptProcessGroupOf :: ProcessHandle -> IO ()


-- | Operations for creating and interacting with sub-processes.
module System.Process

-- | This is the most general way to spawn an external process. The process
grcan be a command line to be executed by a shell or a raw command with
gra list of arguments. The stdin, stdout, and stderr streams of the new
grprocess may individually be attached to new pipes, to existing
gr<a>Handle</a>s, or just inherited from the parent (the default.)
gr
grThe details of how to create the process are passed in the
gr<a>CreateProcess</a> record. To make it easier to construct a
gr<a>CreateProcess</a>, the functions <a>proc</a> and <a>shell</a> are
grsupplied that fill in the fields with default values which can be
groverriden as needed.
gr
gr<a>createProcess</a> returns <tt>(<i>mb_stdin_hdl</i>,
gr<i>mb_stdout_hdl</i>, <i>mb_stderr_hdl</i>, <i>ph</i>)</tt>, where
gr
gr<ul>
gr<li>if <tt><a>std_in</a> == <a>CreatePipe</a></tt>, then
gr<tt><i>mb_stdin_hdl</i></tt> will be <tt>Just <i>h</i></tt>, where
gr<tt><i>h</i></tt> is the write end of the pipe connected to the child
grprocess's <tt>stdin</tt>.</li>
gr<li>otherwise, <tt><i>mb_stdin_hdl</i> == Nothing</tt></li>
gr</ul>
gr
grSimilarly for <tt><i>mb_stdout_hdl</i></tt> and
gr<tt><i>mb_stderr_hdl</i></tt>.
gr
grFor example, to execute a simple <tt>ls</tt> command:
gr
gr<pre>
grr &lt;- createProcess (proc "ls" [])
gr</pre>
gr
grTo create a pipe from which to read the output of <tt>ls</tt>:
gr
gr<pre>
gr(_, Just hout, _, _) &lt;-
gr    createProcess (proc "ls" []){ std_out = CreatePipe }
gr</pre>
gr
grTo also set the directory in which to run <tt>ls</tt>:
gr
gr<pre>
gr(_, Just hout, _, _) &lt;-
gr    createProcess (proc "ls" []){ cwd = Just "\home\bob",
gr                                  std_out = CreatePipe }
gr</pre>
gr
grNote that <tt>Handle</tt>s provided for <tt>std_in</tt>,
gr<tt>std_out</tt>, or <tt>std_err</tt> via the <tt>UseHandle</tt>
grconstructor will be closed by calling this function. This is not
gralways the desired behavior. In cases where you would like to leave
grthe <tt>Handle</tt> open after spawning the child process, please use
gr<a>createProcess_</a> instead. All created <tt>Handle</tt>s are
grinitially in text mode; if you need them to be in binary mode then use
gr<a>hSetBinaryMode</a>.
createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)

-- | This function is almost identical to <a>createProcess</a>. The only
grdifferences are:
gr
gr<ul>
gr<li><a>Handle</a>s provided via <a>UseHandle</a> are not closed
grautomatically.</li>
gr<li>This function takes an extra <tt>String</tt> argument to be used
grin creating error messages.</li>
gr<li><a>use_process_jobs</a> can be set in CreateProcess since 1.5.0.0
grin order to create an I/O completion port to monitor a process tree's
grprogress on Windows.</li>
gr</ul>
gr
grThe function also returns two new handles: * an I/O Completion Port
grhandle on which events will be signaled. * a Job handle which can be
grused to kill all running processes.
gr
grOn POSIX platforms these two new handles will always be Nothing
gr
grThis function has been available from the
gr<a>System.Process.Internals</a> module for some time, and is part of
grthe <a>System.Process</a> module since version 1.2.1.0.
createProcess_ :: String -> CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)

-- | Construct a <a>CreateProcess</a> record for passing to
gr<a>createProcess</a>, representing a command to be passed to the
grshell.
shell :: String -> CreateProcess

-- | Construct a <a>CreateProcess</a> record for passing to
gr<a>createProcess</a>, representing a raw command with arguments.
gr
grSee <a>RawCommand</a> for precise semantics of the specified
gr<tt>FilePath</tt>.
proc :: FilePath -> [String] -> CreateProcess
data CreateProcess
CreateProcess :: CmdSpec -> Maybe FilePath -> Maybe [(String, String)] -> StdStream -> StdStream -> StdStream -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe GroupID -> Maybe UserID -> Bool -> CreateProcess

-- | Executable &amp; arguments, or shell command. If <a>cwd</a> is
gr<a>Nothing</a>, relative paths are resolved with respect to the
grcurrent working directory. If <a>cwd</a> is provided, it is
grimplementation-dependent whether relative paths are resolved with
grrespect to <a>cwd</a> or the current working directory, so absolute
grpaths should be used to ensure portability.
[cmdspec] :: CreateProcess -> CmdSpec

-- | Optional path to the working directory for the new process
[cwd] :: CreateProcess -> Maybe FilePath

-- | Optional environment (otherwise inherit from the current process)
[env] :: CreateProcess -> Maybe [(String, String)]

-- | How to determine stdin
[std_in] :: CreateProcess -> StdStream

-- | How to determine stdout
[std_out] :: CreateProcess -> StdStream

-- | How to determine stderr
[std_err] :: CreateProcess -> StdStream

-- | Close all file descriptors except stdin, stdout and stderr in the new
grprocess (on Windows, only works if std_in, std_out, and std_err are
grall Inherit)
[close_fds] :: CreateProcess -> Bool

-- | Create a new process group
[create_group] :: CreateProcess -> Bool

-- | Delegate control-C handling. Use this for interactive console
grprocesses to let them handle control-C themselves (see below for
grdetails).
gr
grOn Windows this has no effect.
[delegate_ctlc] :: CreateProcess -> Bool

-- | Use the windows DETACHED_PROCESS flag when creating the process; does
grnothing on other platforms.
[detach_console] :: CreateProcess -> Bool

-- | Use the windows CREATE_NEW_CONSOLE flag when creating the process;
grdoes nothing on other platforms.
gr
grDefault: <tt>False</tt>
[create_new_console] :: CreateProcess -> Bool

-- | Use posix setsid to start the new process in a new session; does
grnothing on other platforms.
[new_session] :: CreateProcess -> Bool

-- | Use posix setgid to set child process's group id; does nothing on
grother platforms.
gr
grDefault: <tt>Nothing</tt>
[child_group] :: CreateProcess -> Maybe GroupID

-- | Use posix setuid to set child process's user id; does nothing on other
grplatforms.
gr
grDefault: <tt>Nothing</tt>
[child_user] :: CreateProcess -> Maybe UserID

-- | On Windows systems this flag indicates that we should wait for the
grentire process tree to finish before unblocking. On POSIX systems this
grflag is ignored.
gr
grDefault: <tt>False</tt>
[use_process_jobs] :: CreateProcess -> Bool
data CmdSpec

-- | A command line to execute using the shell
ShellCommand :: String -> CmdSpec

-- | The name of an executable with a list of arguments
gr
grThe <a>FilePath</a> argument names the executable, and is interpreted
graccording to the platform's standard policy for searching for
grexecutables. Specifically:
gr
gr<ul>
gr<li>on Unix systems the <a>execvp(3)</a> semantics is used, where if
grthe executable filename does not contain a slash (<tt>/</tt>) then the
gr<tt>PATH</tt> environment variable is searched for the
grexecutable.</li>
gr<li>on Windows systems the Win32 <tt>CreateProcess</tt> semantics is
grused. Briefly: if the filename does not contain a path, then the
grdirectory containing the parent executable is searched, followed by
grthe current directory, then some standard locations, and finally the
grcurrent <tt>PATH</tt>. An <tt>.exe</tt> extension is added if the
grfilename does not already have an extension. For full details see the
gr<a>documentation</a> for the Windows <tt>SearchPath</tt> API.</li>
gr</ul>
RawCommand :: FilePath -> [String] -> CmdSpec
data StdStream

-- | Inherit Handle from parent
Inherit :: StdStream

-- | Use the supplied Handle
UseHandle :: Handle -> StdStream

-- | Create a new pipe. The returned <tt>Handle</tt> will use the default
grencoding and newline translation mode (just like <tt>Handle</tt>s
grcreated by <tt>openFile</tt>).
CreatePipe :: StdStream

-- | No stream handle will be passed
NoStream :: StdStream
data ProcessHandle

-- | Creates a new process to run the specified command with the given
grarguments, and wait for it to finish. If the command returns a
grnon-zero exit code, an exception is raised.
gr
grIf an asynchronous exception is thrown to the thread executing
gr<tt>callProcess</tt>, the forked process will be terminated and
gr<tt>callProcess</tt> will wait (block) until the process has been
grterminated.
callProcess :: FilePath -> [String] -> IO ()

-- | Creates a new process to run the specified shell command. If the
grcommand returns a non-zero exit code, an exception is raised.
gr
grIf an asynchronous exception is thrown to the thread executing
gr<tt>callCommand</tt>, the forked process will be terminated and
gr<tt>callCommand</tt> will wait (block) until the process has been
grterminated.
callCommand :: String -> IO ()

-- | Creates a new process to run the specified raw command with the given
grarguments. It does not wait for the program to finish, but returns the
gr<a>ProcessHandle</a>.
spawnProcess :: FilePath -> [String] -> IO ProcessHandle

-- | Creates a new process to run the specified shell command. It does not
grwait for the program to finish, but returns the <a>ProcessHandle</a>.
spawnCommand :: String -> IO ProcessHandle

-- | <tt>readCreateProcess</tt> works exactly like <a>readProcess</a>
grexcept that it lets you pass <a>CreateProcess</a> giving better
grflexibility.
gr
gr<pre>
gr&gt; readCreateProcess (shell "pwd" { cwd = "/etc/" }) ""
gr"/etc\n"
gr</pre>
gr
grNote that <tt>Handle</tt>s provided for <tt>std_in</tt> or
gr<tt>std_out</tt> via the CreateProcess record will be ignored.
readCreateProcess :: CreateProcess -> String -> IO String

-- | <tt>readProcess</tt> forks an external process, reads its standard
groutput strictly, blocking until the process terminates, and returns
grthe output string. The external process inherits the standard error.
gr
grIf an asynchronous exception is thrown to the thread executing
gr<tt>readProcess</tt>, the forked process will be terminated and
gr<tt>readProcess</tt> will wait (block) until the process has been
grterminated.
gr
grOutput is returned strictly, so this is not suitable for interactive
grapplications.
gr
grThis function throws an <a>IOError</a> if the process <a>ExitCode</a>
gris anything other than <a>ExitSuccess</a>. If instead you want to get
grthe <a>ExitCode</a> then use <a>readProcessWithExitCode</a>.
gr
grUsers of this function should compile with <tt>-threaded</tt> if they
grwant other Haskell threads to keep running while waiting on the result
grof readProcess.
gr
gr<pre>
gr&gt; readProcess "date" [] []
gr"Thu Feb  7 10:03:39 PST 2008\n"
gr</pre>
gr
grThe arguments are:
gr
gr<ul>
gr<li>The command to run, which must be in the $PATH, or an absolute or
grrelative path</li>
gr<li>A list of separate command line arguments to the program</li>
gr<li>A string to pass on standard input to the forked process.</li>
gr</ul>
readProcess :: FilePath -> [String] -> String -> IO String

-- | <tt>readCreateProcessWithExitCode</tt> works exactly like
gr<a>readProcessWithExitCode</a> except that it lets you pass
gr<a>CreateProcess</a> giving better flexibility.
gr
grNote that <tt>Handle</tt>s provided for <tt>std_in</tt>,
gr<tt>std_out</tt>, or <tt>std_err</tt> via the CreateProcess record
grwill be ignored.
readCreateProcessWithExitCode :: CreateProcess -> String -> IO (ExitCode, String, String)

-- | <tt>readProcessWithExitCode</tt> is like <tt>readProcess</tt> but with
grtwo differences:
gr
gr<ul>
gr<li>it returns the <a>ExitCode</a> of the process, and does not throw
grany exception if the code is not <a>ExitSuccess</a>.</li>
gr<li>it reads and returns the output from process' standard error
grhandle, rather than the process inheriting the standard error
grhandle.</li>
gr</ul>
gr
grOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
grcodes when the process died as the result of a signal.
readProcessWithExitCode :: FilePath -> [String] -> String -> IO (ExitCode, String, String)

-- | A <a>bracket</a>-style resource handler for <a>createProcess</a>.
gr
grDoes automatic cleanup when the action finishes. If there is an
grexception in the body then it ensures that the process gets terminated
grand any <a>CreatePipe</a> <a>Handle</a>s are closed. In particular
grthis means that if the Haskell thread is killed (e.g.
gr<a>killThread</a>), that the external process is also terminated.
gr
gre.g.
gr
gr<pre>
grwithCreateProcess (proc cmd args) { ... }  $ \stdin stdout stderr ph -&gt; do
gr  ...
gr</pre>
withCreateProcess :: CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> IO a) -> IO a

-- | Given a program <tt><i>p</i></tt> and arguments <tt><i>args</i></tt>,
gr<tt>showCommandForUser <i>p</i> <i>args</i></tt> returns a string
grsuitable for pasting into <tt>/bin/sh</tt> (on Unix systems) or
gr<tt>CMD.EXE</tt> (on Windows).
showCommandForUser :: FilePath -> [String] -> String

-- | The platform specific type for a process identifier.
gr
grThis is always an integral type. Width and signedness are platform
grspecific.
type Pid = CPid

-- | Returns the PID (process ID) of a subprocess.
gr
gr<a>Nothing</a> is returned if the handle was already closed. Otherwise
gra PID is returned that remains valid as long as the handle is open.
grThe operating system may reuse the PID as soon as the last handle to
grthe process is closed.
getPid :: ProcessHandle -> IO (Maybe Pid)

-- | Waits for the specified process to terminate, and returns its exit
grcode.
gr
grGHC Note: in order to call <tt>waitForProcess</tt> without blocking
grall the other threads in the system, you must compile the program with
gr<tt>-threaded</tt>.
gr
gr(<i>Since: 1.2.0.0</i>) On Unix systems, a negative value
gr<tt><a>ExitFailure</a> -<i>signum</i></tt> indicates that the child
grwas terminated by signal <tt><i>signum</i></tt>. The signal numbers
grare platform-specific, so to test for a specific signal use the
grconstants provided by <a>System.Posix.Signals</a> in the <tt>unix</tt>
grpackage. Note: core dumps are not reported, use
gr<a>System.Posix.Process</a> if you need this detail.
waitForProcess :: ProcessHandle -> IO ExitCode

-- | This is a non-blocking version of <a>waitForProcess</a>. If the
grprocess is still running, <a>Nothing</a> is returned. If the process
grhas exited, then <tt><a>Just</a> e</tt> is returned where <tt>e</tt>
gris the exit code of the process.
gr
grOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
grcodes when the process died as the result of a signal.
getProcessExitCode :: ProcessHandle -> IO (Maybe ExitCode)

-- | Attempts to terminate the specified process. This function should not
grbe used under normal circumstances - no guarantees are given regarding
grhow cleanly the process is terminated. To check whether the process
grhas indeed terminated, use <a>getProcessExitCode</a>.
gr
grOn Unix systems, <a>terminateProcess</a> sends the process the SIGTERM
grsignal. On Windows systems, the Win32 <tt>TerminateProcess</tt>
grfunction is called, passing an exit code of 1.
gr
grNote: on Windows, if the process was a shell command created by
gr<a>createProcess</a> with <a>shell</a>, or created by
gr<a>runCommand</a> or <a>runInteractiveCommand</a>, then
gr<a>terminateProcess</a> will only terminate the shell, not the command
gritself. On Unix systems, both processes are in a process group and
grwill be terminated together.
terminateProcess :: ProcessHandle -> IO ()

-- | Sends an interrupt signal to the process group of the given process.
gr
grOn Unix systems, it sends the group the SIGINT signal.
gr
grOn Windows systems, it generates a CTRL_BREAK_EVENT and will only work
grfor processes created using <tt>createProcess</tt> and setting the
gr<a>create_group</a> flag
interruptProcessGroupOf :: ProcessHandle -> IO ()

-- | Create a pipe for interprocess communication and return a
gr<tt>(readEnd, writeEnd)</tt> <a>Handle</a> pair.
createPipe :: IO (Handle, Handle)

-- | Create a pipe for interprocess communication and return a
gr<tt>(readEnd, writeEnd)</tt> <a>FD</a> pair.
createPipeFd :: IO (FD, FD)

-- | Runs a raw command, optionally specifying <a>Handle</a>s from which to
grtake the <tt>stdin</tt>, <tt>stdout</tt> and <tt>stderr</tt> channels
grfor the new process (otherwise these handles are inherited from the
grcurrent process).
gr
grAny <a>Handle</a>s passed to <a>runProcess</a> are placed immediately
grin the closed state.
gr
grNote: consider using the more general <a>createProcess</a> instead of
gr<a>runProcess</a>.
runProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> Maybe Handle -> Maybe Handle -> Maybe Handle -> IO ProcessHandle

-- | Runs a command using the shell.
runCommand :: String -> IO ProcessHandle

-- | Runs a raw command, and returns <a>Handle</a>s that may be used to
grcommunicate with the process via its <tt>stdin</tt>, <tt>stdout</tt>
grand <tt>stderr</tt> respectively.
gr
grFor example, to start a process and feed a string to its stdin:
gr
gr<pre>
gr(inp,out,err,pid) &lt;- runInteractiveProcess "..."
grforkIO (hPutStr inp str)
gr</pre>
runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)

-- | Runs a command using the shell, and returns <a>Handle</a>s that may be
grused to communicate with the process via its <tt>stdin</tt>,
gr<tt>stdout</tt>, and <tt>stderr</tt> respectively.
runInteractiveCommand :: String -> IO (Handle, Handle, Handle, ProcessHandle)

-- | Computation <tt>system cmd</tt> returns the exit code produced when
grthe operating system runs the shell command <tt>cmd</tt>.
gr
grThis computation may fail with one of the following <a>IOErrorType</a>
grexceptions:
gr
gr<ul>
gr<li><i><tt>PermissionDenied</tt></i> The process has insufficient
grprivileges to perform the operation.</li>
gr<li><i><tt>ResourceExhausted</tt></i> Insufficient resources are
gravailable to perform the operation.</li>
gr<li><i><tt>UnsupportedOperation</tt></i> The implementation does not
grsupport system calls.</li>
gr</ul>
gr
grOn Windows, <a>system</a> passes the command to the Windows command
grinterpreter (<tt>CMD.EXE</tt> or <tt>COMMAND.COM</tt>), hence Unixy
grshell tricks will not work.
gr
grOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
grcodes when the process died as the result of a signal.
system :: String -> IO ExitCode

-- | The computation <tt><a>rawSystem</a> <i>cmd</i> <i>args</i></tt> runs
grthe operating system command <tt><i>cmd</i></tt> in such a way that it
grreceives as arguments the <tt><i>args</i></tt> strings exactly as
grgiven, with no funny escaping or shell meta-syntax expansion. It will
grtherefore behave more portably between operating systems than
gr<a>system</a>.
gr
grThe return codes and possible failures are the same as for
gr<a>system</a>.
rawSystem :: String -> [String] -> IO ExitCode


-- | Executing an external command.
gr
grThis module provides a simple interface for executing external
grcommands. For a more complex, but more powerful, interface, see the
gr<a>System.Process</a> module.

-- | <i>Deprecated: Use <a>System.Process</a> instead</i>
module System.Cmd

-- | Computation <tt>system cmd</tt> returns the exit code produced when
grthe operating system runs the shell command <tt>cmd</tt>.
gr
grThis computation may fail with one of the following <a>IOErrorType</a>
grexceptions:
gr
gr<ul>
gr<li><i><tt>PermissionDenied</tt></i> The process has insufficient
grprivileges to perform the operation.</li>
gr<li><i><tt>ResourceExhausted</tt></i> Insufficient resources are
gravailable to perform the operation.</li>
gr<li><i><tt>UnsupportedOperation</tt></i> The implementation does not
grsupport system calls.</li>
gr</ul>
gr
grOn Windows, <a>system</a> passes the command to the Windows command
grinterpreter (<tt>CMD.EXE</tt> or <tt>COMMAND.COM</tt>), hence Unixy
grshell tricks will not work.
gr
grOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
grcodes when the process died as the result of a signal.
system :: String -> IO ExitCode

-- | The computation <tt><a>rawSystem</a> <i>cmd</i> <i>args</i></tt> runs
grthe operating system command <tt><i>cmd</i></tt> in such a way that it
grreceives as arguments the <tt><i>args</i></tt> strings exactly as
grgiven, with no funny escaping or shell meta-syntax expansion. It will
grtherefore behave more portably between operating systems than
gr<a>system</a>.
gr
grThe return codes and possible failures are the same as for
gr<a>system</a>.
rawSystem :: String -> [String] -> IO ExitCode
