<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--Rendered using the Haskell Html Library v0.2--> <HTML ><HEAD ><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8" ><TITLE >IDE.System.Process</TITLE ><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css" ><SCRIPT SRC="haddock-util.js" TYPE="text/javascript" ></SCRIPT ><SCRIPT TYPE="text/javascript" >window.onload = function () {setSynopsis("mini_IDE-System-Process.html")};</SCRIPT ></HEAD ><BODY ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="topbar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" " ></TD ><TD CLASS="title" >process-leksah-1.0.1.4: Process libraries</TD ><TD CLASS="topbut" ><A HREF="index.html" >Contents</A ></TD ><TD CLASS="topbut" ><A HREF="doc-index.html" >Index</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="modulebar" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD ><FONT SIZE="6" >IDE.System.Process</FONT ></TD ><TD ALIGN="right" ><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="infohead" >Portability</TD ><TD CLASS="infoval" >non-portable (requires concurrency)</TD ></TR ><TR ><TD CLASS="infohead" >Stability</TD ><TD CLASS="infoval" >experimental</TD ></TR ><TR ><TD CLASS="infohead" >Maintainer</TD ><TD CLASS="infoval" >libraries@haskell.org</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" ><B >Contents</B ></TD ></TR ><TR ><TD ><DL ><DT ><A HREF="#1" >Running sub-processes </A ></DT ><DD ><DL ><DT ><A HREF="#2" >Specific variants of createProcess </A ></DT ></DL ></DD ><DT ><A HREF="#3" >Process completion </A ></DT ></DL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Description</TD ></TR ><TR ><TD CLASS="doc" >Operations for creating and interacting with sub-processes. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" >Synopsis</TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><A HREF="#v%3AcreateProcess" >createProcess</A > :: <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Ashell" >shell</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Aproc" >proc</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ACreateProcess" >CreateProcess</A > = <A HREF="#v%3ACreateProcess" >CreateProcess</A > {<TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="recfield" ><A HREF="#v%3Acmdspec" >cmdspec</A > :: <A HREF="IDE-System-Process.html#t%3ACmdSpec" >CmdSpec</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Acwd" >cwd</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Aenv" >env</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)]</TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Astd_in" >std_in</A > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Astd_out" >std_out</A > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Astd_err" >std_err</A > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Aclose_fds" >close_fds</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ><TR ><TD CLASS="recfield" ><A HREF="#v%3Anew_group" >new_group</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A ></TD ></TR ></TABLE >}</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3ACmdSpec" >CmdSpec</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AShellCommand" >ShellCommand</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ARawCommand" >RawCommand</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AStdStream" >StdStream</A > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="decl" >= <A HREF="#v%3AInherit" >Inherit</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3AUseHandle" >UseHandle</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ></TR ><TR ><TD CLASS="decl" >| <A HREF="#v%3ACreatePipe" >CreatePipe</A ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A HREF="#t%3AProcessHandle" >ProcessHandle</A > </TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArunCommand" >runCommand</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArunProcess" >runProcess</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArunInteractiveCommand" >runInteractiveCommand</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArunInteractiveProcess" >runInteractiveProcess</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreadProcess" >readProcess</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AreadProcessWithExitCode" >readProcessWithExitCode</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3Asystem" >system</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3ArawSystem" >rawSystem</A > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AwaitForProcess" >waitForProcess</A > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AgetProcessExitCode" >getProcessExitCode</A > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A >)</TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AterminateProcess" >terminateProcess</A > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="s8" ></TD ></TR ><TR ><TD CLASS="decl" ><A HREF="#v%3AinterruptProcessGroup" >interruptProcessGroup</A > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="1" ><A NAME="1" >Running sub-processes </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:createProcess" ><A NAME="v%3AcreateProcess" ></A ></A ><B >createProcess</B > :: <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ></TR ><TR ><TD CLASS="doc" ><P >This is the most general way to spawn an external process. The process can be a command line to be executed by a shell or a raw command with a list of arguments. The stdin, stdout, and stderr streams of the new process may individually be attached to new pipes, to existing <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s, or just inherited from the parent (the default.) </P ><P >The details of how to create the process are passed in the <TT ><A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TT > record. To make it easier to construct a <TT ><A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TT >, the functions <TT ><A HREF="IDE-System-Process.html#v%3Aproc" >proc</A ></TT > and <TT ><A HREF="IDE-System-Process.html#v%3Ashell" >shell</A ></TT > are supplied that fill in the fields with default values which can be overriden as needed. </P ><P ><TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT > returns <TT >(mb_stdin_hdl, mb_stdout_hdl, mb_stderr_hdl, p)</TT >, where </P ><UL ><LI > if <TT >std_in == CreatePipe</TT >, then <TT >mb_stdin_hdl</TT > will be <TT >Just h</TT >, where <TT >h</TT > is the write end of the pipe connected to the child process's <TT >stdin</TT >. </LI ><LI > otherwise, <TT >mb_stdin_hdl == Nothing</TT > </LI ></UL ><P >Similarly for <TT >mb_stdout_hdl</TT > and <TT >mb_stderr_hdl</TT >. </P ><P >For example, to execute a simple <TT >ls</TT > command: </P ><PRE > r <- createProcess (proc "ls" []) </PRE ><P >To create a pipe from which to read the output of <TT >ls</TT >: </P ><PRE > (_, Just hout, _, _) <- createProcess (proc "ls" []){ std_out = CreatePipe } </PRE ><P >To also set the directory in which to run <TT >ls</TT >: </P ><PRE > (_, Just hout, _, _) <- createProcess (proc "ls" []){ cwd = Just "\home\bob", std_out = CreatePipe } </PRE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:shell" ><A NAME="v%3Ashell" ></A ></A ><B >shell</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TD ></TR ><TR ><TD CLASS="doc" >Construct a <TT ><A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TT > record for passing to <TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT >, representing a command to be passed to the shell. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:proc" ><A NAME="v%3Aproc" ></A ></A ><B >proc</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TD ></TR ><TR ><TD CLASS="doc" >Construct a <TT ><A HREF="IDE-System-Process.html#t%3ACreateProcess" >CreateProcess</A ></TT > record for passing to <TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT >, representing a raw command with arguments. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:CreateProcess" ><A NAME="t%3ACreateProcess" ></A ></A ><B >CreateProcess</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="5" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:CreateProcess" ><A NAME="v%3ACreateProcess" ></A ></A ><B >CreateProcess</B ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="body" COLSPAN="2" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:cmdspec" ><A NAME="v%3Acmdspec" ></A ></A ><B >cmdspec</B > :: <A HREF="IDE-System-Process.html#t%3ACmdSpec" >CmdSpec</A ></TD ><TD CLASS="rdoc" >Executable & arguments, or shell command </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:cwd" ><A NAME="v%3Acwd" ></A ></A ><B >cwd</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >Optional path to the working directory for the new process </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:env" ><A NAME="v%3Aenv" ></A ></A ><B >env</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)]</TD ><TD CLASS="rdoc" >Optional environment (otherwise inherit from the current process) </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:std_in" ><A NAME="v%3Astd_in" ></A ></A ><B >std_in</B > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ><TD CLASS="rdoc" >How to determine stdin </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:std_out" ><A NAME="v%3Astd_out" ></A ></A ><B >std_out</B > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ><TD CLASS="rdoc" >How to determine stdout </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:std_err" ><A NAME="v%3Astd_err" ></A ></A ><B >std_err</B > :: <A HREF="IDE-System-Process.html#t%3AStdStream" >StdStream</A ></TD ><TD CLASS="rdoc" >How to determine stderr </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:close_fds" ><A NAME="v%3Aclose_fds" ></A ></A ><B >close_fds</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A ></TD ><TD CLASS="rdoc" >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) </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:new_group" ><A NAME="v%3Anew_group" ></A ></A ><B >new_group</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool" >Bool</A ></TD ><TD CLASS="rdoc" >Create a new process group </TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:CmdSpec" ><A NAME="t%3ACmdSpec" ></A ></A ><B >CmdSpec</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:ShellCommand" ><A NAME="v%3AShellCommand" ></A ></A ><B >ShellCommand</B > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >a command line to execute using the shell </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:RawCommand" ><A NAME="v%3ARawCommand" ></A ></A ><B >RawCommand</B > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A > [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ><TD CLASS="rdoc" >the filename of an executable with a list of arguments </TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:StdStream" ><A NAME="t%3AStdStream" ></A ></A ><B >StdStream</B > </TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="section4" >Constructors</TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0" ><TR ><TD CLASS="arg" ><A NAME="v:Inherit" ><A NAME="v%3AInherit" ></A ></A ><B >Inherit</B ></TD ><TD CLASS="rdoc" >Inherit Handle from parent </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:UseHandle" ><A NAME="v%3AUseHandle" ></A ></A ><B >UseHandle</B > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ><TD CLASS="rdoc" >Use the supplied Handle </TD ></TR ><TR ><TD CLASS="arg" ><A NAME="v:CreatePipe" ><A NAME="v%3ACreatePipe" ></A ></A ><B >CreatePipe</B ></TD ><TD CLASS="rdoc" >Create a new pipe </TD ></TR ></TABLE ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><SPAN CLASS="keyword" >data</SPAN > <A NAME="t:ProcessHandle" ><A NAME="t%3AProcessHandle" ></A ></A ><B >ProcessHandle</B > </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section2" ><A NAME="2" ><A NAME="2" >Specific variants of createProcess </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:runCommand" ><A NAME="v%3ArunCommand" ></A ></A ><B >runCommand</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A ></TD ></TR ><TR ><TD CLASS="doc" >Runs a command using the shell. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:runProcess" ><A NAME="v%3ArunProcess" ></A ></A ><B >runProcess</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >Filename of the executable </TD ></TR ><TR ><TD CLASS="arg" >-> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ><TD CLASS="rdoc" >Arguments to pass to the executable </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >Optional path to the working directory </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)]</TD ><TD CLASS="rdoc" >Optional environment (otherwise inherit) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ><TD CLASS="rdoc" >Handle to use for <TT >stdin</TT > (Nothing => use existing <TT >stdin</TT >) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ><TD CLASS="rdoc" >Handle to use for <TT >stdout</TT > (Nothing => use existing <TT >stdout</TT >) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TD ><TD CLASS="rdoc" >Handle to use for <TT >stderr</TT > (Nothing => use existing <TT >stderr</TT >) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >Runs a raw command, optionally specifying <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s from which to take the <TT >stdin</TT >, <TT >stdout</TT > and <TT >stderr</TT > channels for the new process (otherwise these handles are inherited from the current process). </P ><P >Any <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s passed to <TT ><A HREF="IDE-System-Process.html#v%3ArunProcess" >runProcess</A ></TT > are placed immediately in the closed state. </P ><P >Note: consider using the more general <TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT > instead of <TT ><A HREF="IDE-System-Process.html#v%3ArunProcess" >runProcess</A ></TT >. </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:runInteractiveCommand" ><A NAME="v%3ArunInteractiveCommand" ></A ></A ><B >runInteractiveCommand</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ></TR ><TR ><TD CLASS="doc" >Runs a command using the shell, and returns <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s that may be used to communicate with the process via its <TT >stdin</TT >, <TT >stdout</TT >, and <TT >stderr</TT > respectively. The <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s are initially in binary mode; if you need them to be in text mode then use <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#v%3AhSetBinaryMode" >hSetBinaryMode</A ></TT >. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:runInteractiveProcess" ><A NAME="v%3ArunInteractiveProcess" ></A ></A ><B >runInteractiveProcess</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >Filename of the executable </TD ></TR ><TR ><TD CLASS="arg" >-> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ><TD CLASS="rdoc" >Arguments to pass to the executable </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >Optional path to the working directory </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > [(<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)]</TD ><TD CLASS="rdoc" >Optional environment (otherwise inherit) </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A >, <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A >)</TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >Runs a raw command, and returns <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s that may be used to communicate with the process via its <TT >stdin</TT >, <TT >stdout</TT > and <TT >stderr</TT > respectively. </P ><P >For example, to start a process and feed a string to its stdin: </P ><PRE > (inp,out,err,pid) <- runInteractiveProcess "..." forkIO (hPutStr inp str) </PRE ><P >The <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#t%3AHandle" >Handle</A ></TT >s are initially in binary mode; if you need them to be in text mode then use <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/GHC-IO-Handle.html#v%3AhSetBinaryMode" >hSetBinaryMode</A ></TT >. </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:readProcess" ><A NAME="v%3AreadProcess" ></A ></A ><B >readProcess</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >command to run </TD ></TR ><TR ><TD CLASS="arg" >-> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ><TD CLASS="rdoc" >any arguments </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >standard input </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >stdout + stderr </TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >readProcess forks an external process, reads its standard output strictly, blocking until the process terminates, and returns either the output string, or, in the case of non-zero exit status, an error code, and any output. </P ><P >Output is returned strictly, so this is not suitable for interactive applications. </P ><P >Users of this function should compile with <TT >-threaded</TT > if they want other Haskell threads to keep running while waiting on the result of readProcess. </P ><PRE > > readProcess "date" [] [] Right "Thu Feb 7 10:03:39 PST 2008\n" </PRE ><P >The argumenst are: </P ><UL ><LI > The command to run, which must be in the $PATH, or an absolute path </LI ><LI > A list of separate command line arguments to the program </LI ><LI > A string to pass on the standard input to the program. </LI ></UL ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:readProcessWithExitCode" ><A NAME="v%3AreadProcessWithExitCode" ></A ></A ><B >readProcessWithExitCode</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath" >FilePath</A ></TD ><TD CLASS="rdoc" >command to run </TD ></TR ><TR ><TD CLASS="arg" >-> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >]</TD ><TD CLASS="rdoc" >any arguments </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A ></TD ><TD CLASS="rdoc" >standard input </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >, <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >)</TD ><TD CLASS="rdoc" >exitcode, stdout, stderr </TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" ><P >readProcessWithExitCode creates an external process, reads its standard output and standard error strictly, waits until the process terminates, and then returns the <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TT > of the process, the standard output, and the standard error. </P ><P ><TT ><A HREF="IDE-System-Process.html#v%3AreadProcess" >readProcess</A ></TT > and <TT ><A HREF="IDE-System-Process.html#v%3AreadProcessWithExitCode" >readProcessWithExitCode</A ></TT > are fairly simple wrappers around <TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT >. Constructing variants of these functions is quite easy: follow the link to the source code to see how <TT ><A HREF="IDE-System-Process.html#v%3AreadProcess" >readProcess</A ></TT > is implemented. </P ></TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:system" ><A NAME="v%3Asystem" ></A ></A ><B >system</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Computation <TT >system cmd</TT > returns the exit code produced when the operating system runs the shell command <TT >cmd</TT >. </P ><P >This computation may fail with </P ><UL ><LI > <TT >PermissionDenied</TT >: The process has insufficient privileges to perform the operation. </LI ><LI > <TT >ResourceExhausted</TT >: Insufficient resources are available to perform the operation. </LI ><LI > <TT >UnsupportedOperation</TT >: The implementation does not support system calls. </LI ></UL ><P >On Windows, <TT ><A HREF="IDE-System-Process.html#v%3Asystem" >system</A ></TT > passes the command to the Windows command interpreter (<TT >CMD.EXE</TT > or <TT >COMMAND.COM</TT >), hence Unixy shell tricks will not work. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:rawSystem" ><A NAME="v%3ArawSystem" ></A ></A ><B >rawSystem</B > :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A > -> [<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString" >String</A >] -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >The computation <TT ><TT ><A HREF="IDE-System-Process.html#v%3ArawSystem" >rawSystem</A ></TT > cmd args</TT > runs the operating system command <TT >cmd</TT > in such a way that it receives as arguments the <TT >args</TT > strings exactly as given, with no funny escaping or shell meta-syntax expansion. It will therefore behave more portably between operating systems than <TT ><A HREF="IDE-System-Process.html#v%3Asystem" >system</A ></TT >. </P ><P >The return codes and possible failures are the same as for <TT ><A HREF="IDE-System-Process.html#v%3Asystem" >system</A ></TT >. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="section1" ><A NAME="3" ><A NAME="3" >Process completion </A ></A ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:waitForProcess" ><A NAME="v%3AwaitForProcess" ></A ></A ><B >waitForProcess</B > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >Waits for the specified process to terminate, and returns its exit code. </P ><P >GHC Note: in order to call <TT >waitForProcess</TT > without blocking all the other threads in the system, you must compile the program with <TT >-threaded</TT >. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:getProcessExitCode" ><A NAME="v%3AgetProcessExitCode" ></A ></A ><B >getProcessExitCode</B > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#t%3AMaybe" >Maybe</A > <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-Exit.html#t%3AExitCode" >ExitCode</A >)</TD ></TR ><TR ><TD CLASS="doc" >This is a non-blocking version of <TT ><A HREF="IDE-System-Process.html#v%3AwaitForProcess" >waitForProcess</A ></TT >. If the process is still running, <TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#v%3ANothing" >Nothing</A ></TT > is returned. If the process has exited, then <TT ><TT ><A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Maybe.html#v%3AJust" >Just</A ></TT > e</TT > is returned where <TT >e</TT > is the exit code of the process. </TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:terminateProcess" ><A NAME="v%3AterminateProcess" ></A ></A ><B >terminateProcess</B > :: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A > -> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ></TR ><TR ><TD CLASS="doc" ><P >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 <TT ><A HREF="IDE-System-Process.html#v%3AgetProcessExitCode" >getProcessExitCode</A ></TT >. </P ><P >On Unix systems, <TT ><A HREF="IDE-System-Process.html#v%3AterminateProcess" >terminateProcess</A ></TT > sends the process the SIGTERM signal. On Windows systems, the Win32 <TT >TerminateProcess</TT > function is called, passing an exit code of 1. </P ><P >Note: on Windows, if the process was a shell command created by <TT ><A HREF="IDE-System-Process.html#v%3AcreateProcess" >createProcess</A ></TT > with <TT ><A HREF="IDE-System-Process.html#v%3Ashell" >shell</A ></TT >, or created by <TT ><A HREF="IDE-System-Process.html#v%3ArunCommand" >runCommand</A ></TT > or <TT ><A HREF="IDE-System-Process.html#v%3ArunInteractiveCommand" >runInteractiveCommand</A ></TT >, then <TT ><A HREF="IDE-System-Process.html#v%3AterminateProcess" >terminateProcess</A ></TT > will only terminate the shell, not the command itself. On Unix systems, both processes are in a process group and will be terminated together. </P ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="decl" ><A NAME="v:interruptProcessGroup" ><A NAME="v%3AinterruptProcessGroup" ></A ></A ><B >interruptProcessGroup</B ></TD ></TR ><TR ><TD CLASS="body" ><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0" ><TR ><TD CLASS="arg" >:: <A HREF="IDE-System-Process.html#t%3AProcessHandle" >ProcessHandle</A ></TD ><TD CLASS="rdoc" >Lead process in the process group </TD ></TR ><TR ><TD CLASS="arg" >-> <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO" >IO</A > <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29" >()</A ></TD ><TD CLASS="rdoc" ></TD ></TR ><TR ><TD CLASS="ndoc" COLSPAN="2" >Sends and interrupt signal process group. On Unix systems, interuptProcess sends the process group the SIGINT signal. On Windows systems, generates a CTRL_BREAK_EVENT </TD ></TR ></TABLE ></TD ></TR ><TR ><TD CLASS="s15" ></TD ></TR ><TR ><TD CLASS="botbar" >Produced by <A HREF="http://www.haskell.org/haddock/" >Haddock</A > version 2.6.0</TD ></TR ></TABLE ></BODY ></HTML >