Files
dotfiles/cabal/share/doc/x86_64-osx-ghc-7.10.1/MissingH-1.3.0.1/html/System-Cmd-Utils.html
2015-04-05 17:47:08 +02:00

51 lines
35 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>System.Cmd.Utils</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_System-Cmd-Utils.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">MissingH-1.3.0.1: Large utility library</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Copyright</th><td>Copyright (C) 2004-2011 John Goerzen</td></tr><tr><th>License</th><td>BSD3</td></tr><tr><th>Maintainer</th><td>John Goerzen &lt;jgoerzen@complete.org&gt;</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Portability</th><td>portable to platforms with POSIX process\/signal tools</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">System.Cmd.Utils</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">High-Level Tools</a><ul><li><a href="#g:2">Piping with lazy strings</a></li><li><a href="#g:3">Piping with handles</a></li></ul></li><li><a href="#g:4">Low-Level Tools</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Command invocation utilities.</p><p>Written by John Goerzen, jgoerzen@complete.org</p><p>Please note: Most of this module is not compatible with Hugs.</p><p>Command lines executed will be logged using <a href="file:///Users/sidharta/.cabal/share/doc/x86_64-osx-ghc-7.10.1/hslogger-1.2.8/html/System-Log-Logger.html">System.Log.Logger</a> at the
DEBUG level. Failure messages will be logged at the WARNING level in addition
to being raised as an exception. Both are logged under
&quot;System.Cmd.Utils.funcname&quot; -- for instance,
&quot;System.Cmd.Utils.safeSystem&quot;. If you wish to suppress these messages
globally, you can simply run:</p><pre>updateGlobalLogger &quot;System.Cmd.Utils.safeSystem&quot;
(setLevel CRITICAL)</pre><p>See also: <code><a href="file:///Users/sidharta/.cabal/share/doc/x86_64-osx-ghc-7.10.1/hslogger-1.2.8/html/System-Log-Logger.html#v:updateGlobalLogger">updateGlobalLogger</a></code>,
<a href="file:///Users/sidharta/.cabal/share/doc/x86_64-osx-ghc-7.10.1/hslogger-1.2.8/html/System-Log-Logger.html">System.Log.Logger</a>.</p><p>It is possible to set up pipelines with these utilities. Example:</p><pre>(pid1, x1) &lt;- pipeFrom &quot;ls&quot; [&quot;/etc&quot;]
(pid2, x2) &lt;- pipeBoth &quot;grep&quot; [&quot;x&quot;] x1
putStr x2
... the grep output is displayed ...
forceSuccess pid2
forceSuccess pid1</pre><p>Remember, when you use the functions that return a String, you must not call
<code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> until after all data from the String has been consumed. Failure
to wait will cause your program to appear to hang.</p><p>Here is an example of the wrong way to do it:</p><pre>(pid, x) &lt;- pipeFrom &quot;ls&quot; [&quot;/etc&quot;]
forceSuccess pid -- Hangs; the called program hasn't terminated yet
processTheData x</pre><p>You must instead process the data before calling <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code>.</p><p>When using the hPipe family of functions, this is probably more obvious.</p><p>Most of this module will be incompatible with Windows.</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:PipeHandle">PipeHandle</a> = <a href="#v:PipeHandle">PipeHandle</a> {<ul class="subs"><li><a href="#v:processID">processID</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></li><li><a href="#v:phCommand">phCommand</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a></li><li><a href="#v:phArgs">phArgs</a> :: [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>]</li><li><a href="#v:phCreator">phCreator</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></li></ul>}</li><li class="src short"><a href="#v:safeSystem">safeSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:forceSuccess">forceSuccess</a> :: <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</li><li class="src short"><a href="#v:posixRawSystem">posixRawSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-Internals.html#t:ProcessStatus">ProcessStatus</a></li><li class="src short"><a href="#v:forkRawSystem">forkRawSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></li><li class="src short"><a href="#v:pipeFrom">pipeFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>)</li><li class="src short"><a href="#v:pipeLinesFrom">pipeLinesFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>])</li><li class="src short"><a href="#v:pipeTo">pipeTo</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></li><li class="src short"><a href="#v:pipeBoth">pipeBoth</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>)</li><li class="src short"><a href="#v:hPipeFrom">hPipeFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</li><li class="src short"><a href="#v:hPipeTo">hPipeTo</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</li><li class="src short"><a href="#v:hPipeBoth">hPipeBoth</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</li><li class="src short"><span class="keyword">data</span> <a href="#t:PipeMode">PipeMode</a><ul class="subs"><li>= <a href="#v:ReadFromPipe">ReadFromPipe</a></li><li>| <a href="#v:WriteToPipe">WriteToPipe</a></li></ul></li><li class="src short"><a href="#v:pOpen">pOpen</a> :: <a href="System-Cmd-Utils.html#t:PipeMode">PipeMode</a> -&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a) -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:pOpen3">pOpen3</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a) -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> () -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a</li><li class="src short"><a href="#v:pOpen3Raw">pOpen3Raw</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a> -&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> () -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></li></ul></div><div id="interface"><h1 id="g:1">High-Level Tools</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:PipeHandle" class="def">PipeHandle</a></p><div class="doc"><p>Return value from <code><a href="System-Cmd-Utils.html#v:pipeFrom">pipeFrom</a></code>, <code><a href="System-Cmd-Utils.html#v:pipeLinesFrom">pipeLinesFrom</a></code>, <code><a href="System-Cmd-Utils.html#v:pipeTo">pipeTo</a></code>, or
<code><a href="System-Cmd-Utils.html#v:pipeBoth">pipeBoth</a></code>. Contains both a ProcessID and the original command that was
executed. If you prefer not to use <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> on the result of one
of these pipe calls, you can use (processID ph), assuming ph is your <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>,
as a parameter to <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-ByteString.html#v:getProcessStatus">getProcessStatus</a></code>. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:PipeHandle" class="def">PipeHandle</a></td><td class="doc empty">&nbsp;</td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:processID" class="def">processID</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:phCommand" class="def">phCommand</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a></dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:phArgs" class="def">phArgs</a> :: [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>]</dt><dd class="doc empty">&nbsp;</dd><dt class="src"><a name="v:phCreator" class="def">phCreator</a> :: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a></dt><dd class="doc"><p>Function that created it</p></dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:PipeHandle" class="caption collapser" onclick="toggleSection('i:PipeHandle')">Instances</p><div id="section.i:PipeHandle" class="show"><table><tr><td class="src"><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Eq.html#t:Eq">Eq</a> <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Text-Show.html#t:Show">Show</a> <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:safeSystem" class="def">safeSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Invokes the specified command in a subprocess, waiting for the result.
If the command terminated successfully, return normally. Otherwise,
raises a userError with the problem.</p><p>Implemented in terms of <code><a href="System-Cmd-Utils.html#v:posixRawSystem">posixRawSystem</a></code> where supported, and System.Posix.rawSystem otherwise.</p></div></div><div class="top"><p class="src"><a name="v:forceSuccess" class="def">forceSuccess</a> :: <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</p><div class="doc"><p>Uses <code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-ByteString.html#v:getProcessStatus">getProcessStatus</a></code> to obtain the exit status
of the given process ID. If the process terminated normally, does nothing.
Otherwise, raises an exception with an appropriate error message.</p><p>This call will block waiting for the given pid to terminate.</p><p>Not available on Windows. </p></div></div><div class="top"><p class="src"><a name="v:posixRawSystem" class="def">posixRawSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-Internals.html#t:ProcessStatus">ProcessStatus</a></p><div class="doc"><p>Invokes the specified command in a subprocess, waiting for the result.
Return the result status. Never raises an exception. Only available
on POSIX platforms.</p><p>Like system(3), this command ignores SIGINT and SIGQUIT and blocks SIGCHLD
during its execution.</p><p>Logs as System.Cmd.Utils.posixRawSystem </p></div></div><div class="top"><p class="src"><a name="v:forkRawSystem" class="def">forkRawSystem</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></p><div class="doc"><p>Invokes the specified command in a subprocess, without waiting for
the result. Returns the PID of the subprocess -- it is YOUR responsibility
to use getProcessStatus or getAnyProcessStatus on that at some point. Failure
to do so will lead to resource leakage (zombie processes).</p><p>This function does nothing with signals. That too is up to you.</p><p>Logs as System.Cmd.Utils.forkRawSystem </p></div></div><h2 id="g:2">Piping with lazy strings</h2><div class="top"><p class="src"><a name="v:pipeFrom" class="def">pipeFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>)</p><div class="doc"><p>Read data from a pipe. Returns a lazy string and a <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>.</p><p>ONLY AFTER the string has been read completely, You must call either
<code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-ByteString.html#v:getProcessStatus">getProcessStatus</a></code> or <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> on the <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>.
Zombies will result otherwise.</p><p>Not available on Windows.</p></div></div><div class="top"><p class="src"><a name="v:pipeLinesFrom" class="def">pipeLinesFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>])</p><div class="doc"><p>Like <code><a href="System-Cmd-Utils.html#v:pipeFrom">pipeFrom</a></code>, but returns data in lines instead of just a String.
Shortcut for calling lines on the result from <code><a href="System-Cmd-Utils.html#v:pipeFrom">pipeFrom</a></code>.</p><p>Note: this function logs as pipeFrom.</p><p>Not available on Windows. </p></div></div><div class="top"><p class="src"><a name="v:pipeTo" class="def">pipeTo</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></p><div class="doc"><p>Write data to a pipe. Returns a ProcessID.</p><p>You must call either
<code><a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/unix-2.7.1.0/System-Posix-Process-ByteString.html#v:getProcessStatus">getProcessStatus</a></code> or <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> on the ProcessID.
Zombies will result otherwise.</p><p>Not available on Windows.</p></div></div><div class="top"><p class="src"><a name="v:pipeBoth" class="def">pipeBoth</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>)</p><div class="doc"><p>Like a combination of <code><a href="System-Cmd-Utils.html#v:pipeTo">pipeTo</a></code> and <code><a href="System-Cmd-Utils.html#v:pipeFrom">pipeFrom</a></code>; forks an IO thread
to send data to the piped program, and simultaneously returns its output
stream.</p><p>The same note about checking the return status applies here as with <code><a href="System-Cmd-Utils.html#v:pipeFrom">pipeFrom</a></code>.</p><p>Not available on Windows. </p></div></div><h2 id="g:3">Piping with handles</h2><div class="top"><p class="src"><a name="v:hPipeFrom" class="def">hPipeFrom</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</p><div class="doc"><p>Read data from a pipe. Returns a Handle and a <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>.</p><p>When done, you must hClose the handle, and then use either <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> or
getProcessStatus on the <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>. Zombies will result otherwise.</p><p>This function logs as pipeFrom.</p><p>Not available on Windows or with Hugs.</p></div></div><div class="top"><p class="src"><a name="v:hPipeTo" class="def">hPipeTo</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</p><div class="doc"><p>Write data to a pipe. Returns a <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code> and a new Handle to write
to.</p><p>When done, you must hClose the handle, and then use either <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> or
getProcessStatus on the <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>. Zombies will result otherwise.</p><p>This function logs as pipeTo.</p><p>Not available on Windows.</p></div></div><div class="top"><p class="src"><a name="v:hPipeBoth" class="def">hPipeBoth</a> :: <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> (<a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>, <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a>)</p><div class="doc"><p>Like a combination of <code><a href="System-Cmd-Utils.html#v:hPipeTo">hPipeTo</a></code> and <code><a href="System-Cmd-Utils.html#v:hPipeFrom">hPipeFrom</a></code>; returns
a 3-tuple of (<code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>, Data From Pipe, Data To Pipe).</p><p>When done, you must hClose both handles, and then use either <code><a href="System-Cmd-Utils.html#v:forceSuccess">forceSuccess</a></code> or
getProcessStatus on the <code><a href="System-Cmd-Utils.html#t:PipeHandle">PipeHandle</a></code>. Zombies will result otherwise.</p><p>Hint: you will usually need to ForkIO a thread to handle one of the Handles;
otherwise, deadlock can result.</p><p>This function logs as pipeBoth.</p><p>Not available on Windows.</p></div></div><h1 id="g:4">Low-Level Tools</h1><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:PipeMode" class="def">PipeMode</a></p><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:ReadFromPipe" class="def">ReadFromPipe</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a name="v:WriteToPipe" class="def">WriteToPipe</a></td><td class="doc empty">&nbsp;</td></tr></table></div></div><div class="top"><p class="src"><a name="v:pOpen" class="def">pOpen</a> :: <a href="System-Cmd-Utils.html#t:PipeMode">PipeMode</a> -&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a> -&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>] -&gt; (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/GHC-IO-Handle.html#t:Handle">Handle</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a) -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a</p><div class="doc"><p>Open a pipe to the specified command.</p><p>Passes the handle on to the specified function.</p><p>The <code><a href="System-Cmd-Utils.html#t:PipeMode">PipeMode</a></code> specifies what you will be doing. That is, specifing <code><a href="System-Cmd-Utils.html#v:ReadFromPipe">ReadFromPipe</a></code>
sets up a pipe from stdin, and <code><a href="System-Cmd-Utils.html#v:WriteToPipe">WriteToPipe</a></code> sets up a pipe from stdout.</p><p>Not available on Windows.</p></div></div><div class="top"><p class="src"><a name="v:pOpen3" class="def">pOpen3</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Send stdin to this fd</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Get stdout from this fd</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Get stderr from this fd</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a></td><td class="doc"><p>Command to run</p></td></tr><tr><td class="src">-&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>]</td><td class="doc"><p>Command args</p></td></tr><tr><td class="src">-&gt; (<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a> -&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a)</td><td class="doc"><p>Action to run in parent</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</td><td class="doc"><p>Action to run in child before execing (if you don't need something, set this to <code>return ()</code>) -- IGNORED IN HUGS</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> a</td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Runs a command, redirecting things to pipes.</p><p>Not available on Windows.</p><p>Note that you may not use the same fd on more than one item. If you
want to redirect stdout and stderr, dup it first.</p></div></div><div class="top"><p class="src"><a name="v:pOpen3Raw" class="def">pOpen3Raw</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Send stdin to this fd</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Get stdout from this fd</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-Maybe.html#t:Maybe">Maybe</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:Fd">Fd</a></td><td class="doc"><p>Get stderr from this fd</p></td></tr><tr><td class="src">-&gt; <a href="System-IO-HVFS.html#t:FilePath">FilePath</a></td><td class="doc"><p>Command to run</p></td></tr><tr><td class="src">-&gt; [<a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/Data-String.html#t:String">String</a>]</td><td class="doc"><p>Command args</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> ()</td><td class="doc"><p>Action to run in child before execing (if you don't need something, set this to <code>return ()</code>) -- IGNORED IN HUGS</p></td></tr><tr><td class="src">-&gt; <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-IO.html#t:IO">IO</a> <a href="file:///usr/local/Cellar/ghc/7.10.1/share/doc/ghc/html/libraries/base-4.8.0.0/System-Posix-Types.html#t:ProcessID">ProcessID</a></td><td class="doc empty">&nbsp;</td></tr></table></div><div class="doc"><p>Runs a command, redirecting things to pipes.</p><p>Not available on Windows.</p><p>Returns immediately with the PID of the child. Using <code>waitProcess</code> on it
is YOUR responsibility!</p><p>Note that you may not use the same fd on more than one item. If you
want to redirect stdout and stderr, dup it first.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.16.0</p></div></body></html>