úΆ ƒ1     portable experimentallibraries@haskell.org(Create a new pipe Use the supplied Handle Inherit Handle from parent 7the filename of an executable with a list of arguments *a command line to execute using the shell   Executable & arguments, or shell command ;Optional path to the working directory for the new process BOptional environment (otherwise inherit from the current process) How to determine stdin How to determine stdout How to determine stderr —Close all file descriptors except stdin, stdout and stderr in the new process (on Windows, only works if std_in, std_out, and std_err are all Inherit) !"AA handle to a process, which can be used to wait for termination  of the process using waitForProcess. @None of the process-creation functions in this library wait for $ termination: they all return a  which may be used $ to wait for the process later. #$%&'()#function name (for error messages) handler for SIGINT handler for SIGQUIT *+,-./0123ATurns a shell command into a raw command. Usually this involves 0 wrapping it in an invocation of the shell. There'<s a difference in the signature of commandToProcess between J the Windows and Unix versions. On Unix, exec takes a list of strings, & and we want to pass our command to binsh as a single argument. AOn Windows, CreateProcess takes a single string for the command, E which is later decomposed by cmd.exe. In this case, we just want  to prepend "c:WINDOWSCMD.EXE /c" to our command line. The A command-line translation that we normally do for arguments on  Windows isn' t required (or desirable) here. 45"678  !"#$%&'()+,45   !!"$##$%&'()+,45#non-portable (requires concurrency) experimentallibraries@haskell.org9:; Runs a command using the shell. *Runs a raw command, optionally specifying <s from which to  take the stdin, stdout and stderr channels for the new E process (otherwise these handles are inherited from the current  process). Any < s passed to  are placed immediately in the  closed state. &Note: consider using the more general  instead of  . Filename of the executable $Arguments to pass to the executable 'Optional path to the working directory )Optional environment (otherwise inherit) Handle to use for stdin (Nothing => use existing stdin) Handle to use for stdout (Nothing => use existing stdout) Handle to use for stderr (Nothing => use existing stderr)  Construct a  record for passing to , , representing a raw command with arguments.  Construct a  record for passing to , 3 representing a command to be passed to the shell. @This is the most general way to spawn an external process. The Iprocess can be a command line to be executed by a shell or a raw command Dwith a list of arguments. The stdin, stdout, and stderr streams of Gthe new process may individually be attached to new pipes, to existing <4s, or just inherited from the parent (the default.) ;The details of how to create the process are passed in the + record. To make it easier to construct a , the functions  and  are supplied that Afill in the fields with default values which can be overriden as needed.  returns /(mb_stdin_hdl, mb_stdout_hdl, mb_stderr_hdl, p), where  if std_in == CreatePipe, then  mb_stdin_hdl will be Just h,  where h5 is the write end of the pipe connected to the child  process's stdin.  otherwise, mb_stdin_hdl == Nothing Similarly for  mb_stdout_hdl and  mb_stderr_hdl. !For example, to execute a simple ls command:  % r <- createProcess (proc "ls" []) 2To create a pipe from which to read the output of ls:   (_, Just hout, _, _) <- < createProcess (proc "ls" []){ std_out = CreatePipe } *To also set the directory in which to run ls:  (_, Just hout, _, _) <- = createProcess (proc "ls" []){ cwd = Just "\home\bob", < std_out = CreatePipe } ,Runs a command using the shell, and returns < s that may 5 be used to communicate with the process via its stdin, stdout,  and stderr respectively. The <s are initially in binary 8 mode; if you need them to be in text mode then use =.  Runs a raw command, and returns <"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:  4 (inp,out,err,pid) <- runInteractiveProcess "..."  forkIO (hPutStr inp str) The <7s are initially in binary mode; if you need them to be  in text mode then use =. Filename of the executable $Arguments to pass to the executable 'Optional path to the working directory )Optional environment (otherwise inherit) >IWaits for the specified process to terminate, and returns its exit code. GHC Note: in order to call waitForProcess without blocking all the D other threads in the system, you must compile the program with   -threaded. AreadProcess forks an external process, reads its standard output P strictly, blocking until the process terminates, and returns either the output E string, or, in the case of non-zero exit status, an error code, and  any output. 9Output is returned strictly, so this is not suitable for  interactive applications. +Users of this function should compile with  -threaded if they = want other Haskell threads to keep running while waiting on  the result of readProcess.   > readProcess "date" [] [] ) Right "Thu Feb 7 10:03:39 PST 2008\n" The argumenst are: F The command to run, which must be in the $PATH, or an absolute path : A list of separate command line arguments to the program 8 A string to pass on the standard input to the program. command to run any arguments standard input stdout + stderr ?readProcessWithExitCode creates an external process, reads its Estandard output and standard error strictly, waits until the process !terminates, and then returns the ? of the process, -the standard output, and the standard error.  and  are fairly simple wrappers around /. Constructing variants of these functions is :quite easy: follow the link to the source code to see how  is implemented. command to run any arguments standard input exitcode, stdout, stderr  Computation  system cmd) returns the exit code produced when the (operating system runs the shell command cmd. This computation may fail with  PermissionDenied-: The process has insufficient privileges to  perform the operation.  ResourceExhausted*: Insufficient resources are available to  perform the operation.  UnsupportedOperation&: The implementation does not support  system calls.  On Windows, + passes the command to the Windows command  interpreter (CMD.EXE or  COMMAND.COM), hence Unixy shell tricks will not work. @The computation  cmd args# runs the operating system command cmd1 in such a way that it receives as arguments the args strings Iexactly as given, with no funny escaping or shell meta-syntax expansion. FIt will therefore behave more portably between operating systems than . ;The return codes and possible failures are the same as for . CAttempts to terminate the specified process. This function should L not be used under normal circumstances - no guarantees are given regarding F how cleanly the process is terminated. To check whether the process  has indeed terminated, use . On Unix systems, ' sends the process the SIGTERM signal.  On Windows systems, the Win32 TerminateProcess function is called, passing  an exit code of 1. @Note: on Windows, if the process was a shell command created by   with , or created by  or  , then  will only E terminate the shell, not the command itself. On Unix systems, both C processes are in a process group and will be terminated together. "This is a non-blocking version of . If the process is still running, A/ is returned. If the process has exited, then B e is returned where e" is the exit code of the process.   portable provisionallibraries@haskell.orgC       !"#$%&'()*+,-./0123456789:;<=;<>?@A8BC8DEF8GHI8JK8JLMprocess-1.0.1.3System.ProcessSystem.Process.Internals System.Cmd StdStream CreatePipe UseHandleInheritCmdSpec RawCommand ShellCommand CreateProcesscmdspeccwdenvstd_instd_outstd_err close_fds ProcessHandle runCommand runProcessprocshell createProcessrunInteractiveCommandrunInteractiveProcesswaitForProcess readProcessreadProcessWithExitCodesystem rawSystemterminateProcessgetProcessExitCodec_runInteractiveProcessPHANDLEProcessHandle__ ClosedHandle OpenHandlewithProcessHandlewithProcessHandle_mkProcessHandle closePHANDLErunGenProcess_runInteractiveProcess_lock ignoreSignal defaultSignalfd_stdin fd_stdout fd_stderrmbFdmbPipe pfdToHandlecommandToProcesswithFilePathExceptionwithCEnvironmentbaseGHC.IO.Handle.FD fdToHandle unix-2.4.0.2System.Posix.Process.InternalspPrPr_disableITimers c_execvpec_waitForProcessc_getProcessExitCodec_terminateProcessGHC.IO.Handle.TypesHandle GHC.IO.HandlehSetBinaryModerunInteractiveProcess1GHC.IO.ExceptionExitCode syncProcess Data.MaybeNothingJust