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


-- | Process libraries
°5u
°5uThis package contains libraries for dealing with system processes.
°5u
°5uThe typed-process package is a more recent take on a process API,
°5uwhich uses this package internally. It features better binary support,
°5ueasier concurrency, and a more composable API. You can read more about
°5uit 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
°5umay change anytime. If you want a more stable API, use
°5u<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
°5uthe process using <a>waitForProcess</a>.
°5u
°5uNone of the process-creation functions in this library wait for
°5utermination: they all return a <a>ProcessHandle</a> which may be used
°5uto wait for the process later.
°5u
°5uOn Windows a second wait method can be used to block for event
°5ucompletion. This requires two handles. A process job handle and a
°5uevents 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
°5u<a>Nothing</a>, relative paths are resolved with respect to the
°5ucurrent working directory. If <a>cwd</a> is provided, it is
°5uimplementation-dependent whether relative paths are resolved with
°5urespect to <a>cwd</a> or the current working directory, so absolute
°5upaths 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
°5uprocess (on Windows, only works if std_in, std_out, and std_err are
°5uall Inherit)
[close_fds] :: CreateProcess -> Bool

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

-- | Delegate control-C handling. Use this for interactive console
°5uprocesses to let them handle control-C themselves (see below for
°5udetails).
°5u
°5uOn Windows this has no effect.
[delegate_ctlc] :: CreateProcess -> Bool

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

-- | Use the windows CREATE_NEW_CONSOLE flag when creating the process;
°5udoes nothing on other platforms.
°5u
°5uDefault: <tt>False</tt>
[create_new_console] :: CreateProcess -> Bool

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

-- | Use posix setgid to set child process's group id; does nothing on
°5uother platforms.
°5u
°5uDefault: <tt>Nothing</tt>
[child_group] :: CreateProcess -> Maybe GroupID

-- | Use posix setuid to set child process's user id; does nothing on other
°5uplatforms.
°5u
°5uDefault: <tt>Nothing</tt>
[child_user] :: CreateProcess -> Maybe UserID

-- | On Windows systems this flag indicates that we should wait for the
°5uentire process tree to finish before unblocking. On POSIX systems this
°5uflag is ignored.
°5u
°5uDefault: <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
°5u
°5uThe <a>FilePath</a> argument names the executable, and is interpreted
°5uaccording to the platform's standard policy for searching for
°5uexecutables. Specifically:
°5u
°5u<ul>
°5u<li>on Unix systems the <a>execvp(3)</a> semantics is used, where if
°5uthe executable filename does not contain a slash (<tt>/</tt>) then the
°5u<tt>PATH</tt> environment variable is searched for the
°5uexecutable.</li>
°5u<li>on Windows systems the Win32 <tt>CreateProcess</tt> semantics is
°5uused. Briefly: if the filename does not contain a path, then the
°5udirectory containing the parent executable is searched, followed by
°5uthe current directory, then some standard locations, and finally the
°5ucurrent <tt>PATH</tt>. An <tt>.exe</tt> extension is added if the
°5ufilename does not already have an extension. For full details see the
°5u<a>documentation</a> for the Windows <tt>SearchPath</tt> API.</li>
°5u</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
°5uencoding and newline translation mode (just like <tt>Handle</tt>s
°5ucreated 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
°5udifferences are:
°5u
°5u<ul>
°5u<li><a>Handle</a>s provided via <a>UseHandle</a> are not closed
°5uautomatically.</li>
°5u<li>This function takes an extra <tt>String</tt> argument to be used
°5uin creating error messages.</li>
°5u<li><a>use_process_jobs</a> can be set in CreateProcess since 1.5.0.0
°5uin order to create an I/O completion port to monitor a process tree's
°5uprogress on Windows.</li>
°5u</ul>
°5u
°5uThe function also returns two new handles: * an I/O Completion Port
°5uhandle on which events will be signaled. * a Job handle which can be
°5uused to kill all running processes.
°5u
°5uOn POSIX platforms these two new handles will always be Nothing
°5u
°5uThis function has been available from the
°5u<a>System.Process.Internals</a> module for some time, and is part of
°5uthe <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
°5u<a>createProcess</a>. If you need the SIGINT handling, use
°5udelegate_ctlc = True (runGenProcess_ is now just an imperfectly
°5uemulated stub that probably duplicates or overrides your own signal
°5uhandling).</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
°5uvarious external libraries to make Handles.
°5u
°5uMakes a binary Handle. This is for historical reasons; it should
°5uprobably be a text Handle with the default encoding and newline
°5utranslation 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
°5u<tt>(readEnd, writeEnd)</tt> <a>Handle</a> pair.
createPipe :: IO (Handle, Handle)

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

-- | Sends an interrupt signal to the process group of the given process.
°5u
°5uOn Unix systems, it sends the group the SIGINT signal.
°5u
°5uOn Windows systems, it generates a CTRL_BREAK_EVENT and will only work
°5ufor processes created using <tt>createProcess</tt> and setting the
°5u<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
°5ucan be a command line to be executed by a shell or a raw command with
°5ua list of arguments. The stdin, stdout, and stderr streams of the new
°5uprocess may individually be attached to new pipes, to existing
°5u<a>Handle</a>s, or just inherited from the parent (the default.)
°5u
°5uThe details of how to create the process are passed in the
°5u<a>CreateProcess</a> record. To make it easier to construct a
°5u<a>CreateProcess</a>, the functions <a>proc</a> and <a>shell</a> are
°5usupplied that fill in the fields with default values which can be
°5uoverriden as needed.
°5u
°5u<a>createProcess</a> returns <tt>(<i>mb_stdin_hdl</i>,
°5u<i>mb_stdout_hdl</i>, <i>mb_stderr_hdl</i>, <i>ph</i>)</tt>, where
°5u
°5u<ul>
°5u<li>if <tt><a>std_in</a> == <a>CreatePipe</a></tt>, then
°5u<tt><i>mb_stdin_hdl</i></tt> will be <tt>Just <i>h</i></tt>, where
°5u<tt><i>h</i></tt> is the write end of the pipe connected to the child
°5uprocess's <tt>stdin</tt>.</li>
°5u<li>otherwise, <tt><i>mb_stdin_hdl</i> == Nothing</tt></li>
°5u</ul>
°5u
°5uSimilarly for <tt><i>mb_stdout_hdl</i></tt> and
°5u<tt><i>mb_stderr_hdl</i></tt>.
°5u
°5uFor example, to execute a simple <tt>ls</tt> command:
°5u
°5u<pre>
°5ur &lt;- createProcess (proc "ls" [])
°5u</pre>
°5u
°5uTo create a pipe from which to read the output of <tt>ls</tt>:
°5u
°5u<pre>
°5u(_, Just hout, _, _) &lt;-
°5u    createProcess (proc "ls" []){ std_out = CreatePipe }
°5u</pre>
°5u
°5uTo also set the directory in which to run <tt>ls</tt>:
°5u
°5u<pre>
°5u(_, Just hout, _, _) &lt;-
°5u    createProcess (proc "ls" []){ cwd = Just "\home\bob",
°5u                                  std_out = CreatePipe }
°5u</pre>
°5u
°5uNote that <tt>Handle</tt>s provided for <tt>std_in</tt>,
°5u<tt>std_out</tt>, or <tt>std_err</tt> via the <tt>UseHandle</tt>
°5uconstructor will be closed by calling this function. This is not
°5ualways the desired behavior. In cases where you would like to leave
°5uthe <tt>Handle</tt> open after spawning the child process, please use
°5u<a>createProcess_</a> instead. All created <tt>Handle</tt>s are
°5uinitially in text mode; if you need them to be in binary mode then use
°5u<a>hSetBinaryMode</a>.
createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)

-- | This function is almost identical to <a>createProcess</a>. The only
°5udifferences are:
°5u
°5u<ul>
°5u<li><a>Handle</a>s provided via <a>UseHandle</a> are not closed
°5uautomatically.</li>
°5u<li>This function takes an extra <tt>String</tt> argument to be used
°5uin creating error messages.</li>
°5u<li><a>use_process_jobs</a> can be set in CreateProcess since 1.5.0.0
°5uin order to create an I/O completion port to monitor a process tree's
°5uprogress on Windows.</li>
°5u</ul>
°5u
°5uThe function also returns two new handles: * an I/O Completion Port
°5uhandle on which events will be signaled. * a Job handle which can be
°5uused to kill all running processes.
°5u
°5uOn POSIX platforms these two new handles will always be Nothing
°5u
°5uThis function has been available from the
°5u<a>System.Process.Internals</a> module for some time, and is part of
°5uthe <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
°5u<a>createProcess</a>, representing a command to be passed to the
°5ushell.
shell :: String -> CreateProcess

-- | Construct a <a>CreateProcess</a> record for passing to
°5u<a>createProcess</a>, representing a raw command with arguments.
°5u
°5uSee <a>RawCommand</a> for precise semantics of the specified
°5u<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
°5u<a>Nothing</a>, relative paths are resolved with respect to the
°5ucurrent working directory. If <a>cwd</a> is provided, it is
°5uimplementation-dependent whether relative paths are resolved with
°5urespect to <a>cwd</a> or the current working directory, so absolute
°5upaths 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
°5uprocess (on Windows, only works if std_in, std_out, and std_err are
°5uall Inherit)
[close_fds] :: CreateProcess -> Bool

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

-- | Delegate control-C handling. Use this for interactive console
°5uprocesses to let them handle control-C themselves (see below for
°5udetails).
°5u
°5uOn Windows this has no effect.
[delegate_ctlc] :: CreateProcess -> Bool

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

-- | Use the windows CREATE_NEW_CONSOLE flag when creating the process;
°5udoes nothing on other platforms.
°5u
°5uDefault: <tt>False</tt>
[create_new_console] :: CreateProcess -> Bool

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

-- | Use posix setgid to set child process's group id; does nothing on
°5uother platforms.
°5u
°5uDefault: <tt>Nothing</tt>
[child_group] :: CreateProcess -> Maybe GroupID

-- | Use posix setuid to set child process's user id; does nothing on other
°5uplatforms.
°5u
°5uDefault: <tt>Nothing</tt>
[child_user] :: CreateProcess -> Maybe UserID

-- | On Windows systems this flag indicates that we should wait for the
°5uentire process tree to finish before unblocking. On POSIX systems this
°5uflag is ignored.
°5u
°5uDefault: <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
°5u
°5uThe <a>FilePath</a> argument names the executable, and is interpreted
°5uaccording to the platform's standard policy for searching for
°5uexecutables. Specifically:
°5u
°5u<ul>
°5u<li>on Unix systems the <a>execvp(3)</a> semantics is used, where if
°5uthe executable filename does not contain a slash (<tt>/</tt>) then the
°5u<tt>PATH</tt> environment variable is searched for the
°5uexecutable.</li>
°5u<li>on Windows systems the Win32 <tt>CreateProcess</tt> semantics is
°5uused. Briefly: if the filename does not contain a path, then the
°5udirectory containing the parent executable is searched, followed by
°5uthe current directory, then some standard locations, and finally the
°5ucurrent <tt>PATH</tt>. An <tt>.exe</tt> extension is added if the
°5ufilename does not already have an extension. For full details see the
°5u<a>documentation</a> for the Windows <tt>SearchPath</tt> API.</li>
°5u</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
°5uencoding and newline translation mode (just like <tt>Handle</tt>s
°5ucreated 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
°5uarguments, and wait for it to finish. If the command returns a
°5unon-zero exit code, an exception is raised.
°5u
°5uIf an asynchronous exception is thrown to the thread executing
°5u<tt>callProcess</tt>, the forked process will be terminated and
°5u<tt>callProcess</tt> will wait (block) until the process has been
°5uterminated.
callProcess :: FilePath -> [String] -> IO ()

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

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

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

-- | <tt>readCreateProcess</tt> works exactly like <a>readProcess</a>
°5uexcept that it lets you pass <a>CreateProcess</a> giving better
°5uflexibility.
°5u
°5u<pre>
°5u&gt; readCreateProcess (shell "pwd" { cwd = "/etc/" }) ""
°5u"/etc\n"
°5u</pre>
°5u
°5uNote that <tt>Handle</tt>s provided for <tt>std_in</tt> or
°5u<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
°5uoutput strictly, blocking until the process terminates, and returns
°5uthe output string. The external process inherits the standard error.
°5u
°5uIf an asynchronous exception is thrown to the thread executing
°5u<tt>readProcess</tt>, the forked process will be terminated and
°5u<tt>readProcess</tt> will wait (block) until the process has been
°5uterminated.
°5u
°5uOutput is returned strictly, so this is not suitable for interactive
°5uapplications.
°5u
°5uThis function throws an <a>IOError</a> if the process <a>ExitCode</a>
°5uis anything other than <a>ExitSuccess</a>. If instead you want to get
°5uthe <a>ExitCode</a> then use <a>readProcessWithExitCode</a>.
°5u
°5uUsers of this function should compile with <tt>-threaded</tt> if they
°5uwant other Haskell threads to keep running while waiting on the result
°5uof readProcess.
°5u
°5u<pre>
°5u&gt; readProcess "date" [] []
°5u"Thu Feb  7 10:03:39 PST 2008\n"
°5u</pre>
°5u
°5uThe arguments are:
°5u
°5u<ul>
°5u<li>The command to run, which must be in the $PATH, or an absolute or
°5urelative path</li>
°5u<li>A list of separate command line arguments to the program</li>
°5u<li>A string to pass on standard input to the forked process.</li>
°5u</ul>
readProcess :: FilePath -> [String] -> String -> IO String

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

-- | <tt>readProcessWithExitCode</tt> is like <tt>readProcess</tt> but with
°5utwo differences:
°5u
°5u<ul>
°5u<li>it returns the <a>ExitCode</a> of the process, and does not throw
°5uany exception if the code is not <a>ExitSuccess</a>.</li>
°5u<li>it reads and returns the output from process' standard error
°5uhandle, rather than the process inheriting the standard error
°5uhandle.</li>
°5u</ul>
°5u
°5uOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
°5ucodes 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>.
°5u
°5uDoes automatic cleanup when the action finishes. If there is an
°5uexception in the body then it ensures that the process gets terminated
°5uand any <a>CreatePipe</a> <a>Handle</a>s are closed. In particular
°5uthis means that if the Haskell thread is killed (e.g.
°5u<a>killThread</a>), that the external process is also terminated.
°5u
°5ue.g.
°5u
°5u<pre>
°5uwithCreateProcess (proc cmd args) { ... }  $ \stdin stdout stderr ph -&gt; do
°5u  ...
°5u</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>,
°5u<tt>showCommandForUser <i>p</i> <i>args</i></tt> returns a string
°5usuitable for pasting into <tt>/bin/sh</tt> (on Unix systems) or
°5u<tt>CMD.EXE</tt> (on Windows).
showCommandForUser :: FilePath -> [String] -> String

-- | The platform specific type for a process identifier.
°5u
°5uThis is always an integral type. Width and signedness are platform
°5uspecific.
type Pid = CPid

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

-- | Waits for the specified process to terminate, and returns its exit
°5ucode.
°5u
°5uGHC Note: in order to call <tt>waitForProcess</tt> without blocking
°5uall the other threads in the system, you must compile the program with
°5u<tt>-threaded</tt>.
°5u
°5u(<i>Since: 1.2.0.0</i>) On Unix systems, a negative value
°5u<tt><a>ExitFailure</a> -<i>signum</i></tt> indicates that the child
°5uwas terminated by signal <tt><i>signum</i></tt>. The signal numbers
°5uare platform-specific, so to test for a specific signal use the
°5uconstants provided by <a>System.Posix.Signals</a> in the <tt>unix</tt>
°5upackage. Note: core dumps are not reported, use
°5u<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
°5uprocess is still running, <a>Nothing</a> is returned. If the process
°5uhas exited, then <tt><a>Just</a> e</tt> is returned where <tt>e</tt>
°5uis the exit code of the process.
°5u
°5uOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
°5ucodes 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
°5ube used under normal circumstances - no guarantees are given regarding
°5uhow cleanly the process is terminated. To check whether the process
°5uhas indeed terminated, use <a>getProcessExitCode</a>.
°5u
°5uOn Unix systems, <a>terminateProcess</a> sends the process the SIGTERM
°5usignal. On Windows systems, the Win32 <tt>TerminateProcess</tt>
°5ufunction is called, passing an exit code of 1.
°5u
°5uNote: on Windows, if the process was a shell command created by
°5u<a>createProcess</a> with <a>shell</a>, or created by
°5u<a>runCommand</a> or <a>runInteractiveCommand</a>, then
°5u<a>terminateProcess</a> will only terminate the shell, not the command
°5uitself. On Unix systems, both processes are in a process group and
°5uwill be terminated together.
terminateProcess :: ProcessHandle -> IO ()

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

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

-- | Create a pipe for interprocess communication and return a
°5u<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
°5utake the <tt>stdin</tt>, <tt>stdout</tt> and <tt>stderr</tt> channels
°5ufor the new process (otherwise these handles are inherited from the
°5ucurrent process).
°5u
°5uAny <a>Handle</a>s passed to <a>runProcess</a> are placed immediately
°5uin the closed state.
°5u
°5uNote: consider using the more general <a>createProcess</a> instead of
°5u<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
°5ucommunicate with the process via its <tt>stdin</tt>, <tt>stdout</tt>
°5uand <tt>stderr</tt> respectively.
°5u
°5uFor example, to start a process and feed a string to its stdin:
°5u
°5u<pre>
°5u(inp,out,err,pid) &lt;- runInteractiveProcess "..."
°5uforkIO (hPutStr inp str)
°5u</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
°5uused to communicate with the process via its <tt>stdin</tt>,
°5u<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
°5uthe operating system runs the shell command <tt>cmd</tt>.
°5u
°5uThis computation may fail with one of the following <a>IOErrorType</a>
°5uexceptions:
°5u
°5u<ul>
°5u<li><i><tt>PermissionDenied</tt></i> The process has insufficient
°5uprivileges to perform the operation.</li>
°5u<li><i><tt>ResourceExhausted</tt></i> Insufficient resources are
°5uavailable to perform the operation.</li>
°5u<li><i><tt>UnsupportedOperation</tt></i> The implementation does not
°5usupport system calls.</li>
°5u</ul>
°5u
°5uOn Windows, <a>system</a> passes the command to the Windows command
°5uinterpreter (<tt>CMD.EXE</tt> or <tt>COMMAND.COM</tt>), hence Unixy
°5ushell tricks will not work.
°5u
°5uOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
°5ucodes 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
°5uthe operating system command <tt><i>cmd</i></tt> in such a way that it
°5ureceives as arguments the <tt><i>args</i></tt> strings exactly as
°5ugiven, with no funny escaping or shell meta-syntax expansion. It will
°5utherefore behave more portably between operating systems than
°5u<a>system</a>.
°5u
°5uThe return codes and possible failures are the same as for
°5u<a>system</a>.
rawSystem :: String -> [String] -> IO ExitCode


-- | Executing an external command.
°5u
°5uThis module provides a simple interface for executing external
°5ucommands. For a more complex, but more powerful, interface, see the
°5u<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
°5uthe operating system runs the shell command <tt>cmd</tt>.
°5u
°5uThis computation may fail with one of the following <a>IOErrorType</a>
°5uexceptions:
°5u
°5u<ul>
°5u<li><i><tt>PermissionDenied</tt></i> The process has insufficient
°5uprivileges to perform the operation.</li>
°5u<li><i><tt>ResourceExhausted</tt></i> Insufficient resources are
°5uavailable to perform the operation.</li>
°5u<li><i><tt>UnsupportedOperation</tt></i> The implementation does not
°5usupport system calls.</li>
°5u</ul>
°5u
°5uOn Windows, <a>system</a> passes the command to the Windows command
°5uinterpreter (<tt>CMD.EXE</tt> or <tt>COMMAND.COM</tt>), hence Unixy
°5ushell tricks will not work.
°5u
°5uOn Unix systems, see <a>waitForProcess</a> for the meaning of exit
°5ucodes 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
°5uthe operating system command <tt><i>cmd</i></tt> in such a way that it
°5ureceives as arguments the <tt><i>args</i></tt> strings exactly as
°5ugiven, with no funny escaping or shell meta-syntax expansion. It will
°5utherefore behave more portably between operating systems than
°5u<a>system</a>.
°5u
°5uThe return codes and possible failures are the same as for
°5u<a>system</a>.
rawSystem :: String -> [String] -> IO ExitCode
