Proposal: overhaul System.Process
Simon Marlow
marlowsd at gmail.com
Tue Apr 29 13:14:44 EDT 2008
David Roundy wrote:
> Why not then leave the stderr out of the output, and just print it to
> stderr? It's the standard location to send error output, and I'd hate to
> lose it.
Ok, so here's the new proposal:
readProcess
:: FilePath -- ^ command to run
-> [String] -- ^ any arguments
-> String -- ^ standard input
-> IO String -- ^ stdout only (stderr is inherited)
readProcessWithExitCode
:: FilePath -- ^ command to run
-> [String] -- ^ any arguments
-> String -- ^ standard input
-> IO (ExitCode,String) -- ^ exitcode, and stdout + stderr
There's an inconsistency between the two variants in where stderr goes,
but that seems unavoidable. And you can always roll your own if you
want something different, it's only 12 lines of code and all the pieces
are available separately. We can put the code for one of them in the
docs as an example. Ok?
I'm also thinking of adding
closeFds :: Bool
to the CreateProcess record, to indicate that all FDs except 0..2 should
be closed in the child. Python's version has this:
http://docs.python.org/lib/node528.html
(which is suspiciously similar to ours, clearly great minds think alike :-)
and we have a ticket open for this in GHC:
http://hackage.haskell.org/trac/ghc/ticket/1415
Cheers,
Simon
More information about the Libraries
mailing list