[Haskell-cafe] Re: ANN: HSH 1.2.0
simonmarhaskell at gmail.com
Tue Mar 6 06:26:18 EST 2007
John Goerzen wrote:
> On Mon, Mar 05, 2007 at 01:30:23PM +0000, Simon Marlow wrote:
>>> I don't know how Windows shells deal with piping, or even if they
>>> can. All I know is that DOS used to simulate it with temporary files,
>>> lacking any real multitasking.
>> Windows has proper pipes these days, and
>> System.Process.runInteractiveProcess creates pipes for you.
> But it is not suitable for this purpose. It returns Handles, but it
> doesn't let me specify Handles going in. That means that it is not
> possible to create a pipe going directly from program A to program B.
You certainly can pipe directly from one process to another:
main = do
(hin,hout,herr,p1) <- runInteractiveCommand "cat pipe.hs"
p2 <- runProcess "tr" ["A-Z","a-z"] Nothing Nothing
(Just hout) Nothing Nothing
waitForProcess p1 >>= print
waitForProcess p2 >>= print
However, I'll accept that there are certain arrangements of pipes that aren't
possible, or will construct too many pipes and you'll need extra threads to
connect them together, because the only way to create pipes is with
runInteractive* and that creates pipes for all of stdin/stdout/stderr.
Of course we're open to suggestions for improving System.Process. Perhaps there
should be a version that lets you specify a Handle *or* create a pipe, for each
standard file descriptor.
More information about the Haskell-Cafe