[Haskell-cafe] No handles from createProcess

Roman Cheplyaka roma at ro-che.info
Mon Dec 15 16:27:29 UTC 2014


The documentation for createProcess seems pretty clear on this:

if std_in == CreatePipe, then mb_stdin_hdl will be Just h, where h 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.

proc doesn't set std_in to CreatePipe; you need to do that yourself if
you need it.

On 15/12/14 16:11, Henk-Jan van Tuyl wrote:
> 
> L.S.,
> 
> I am experimenting with the createProcess function from the package
> "process"; this function does not return any handle, on both Ubuntu and
> Windows. I am doing something wrong, or is this a bug? (I am using GHC
> 7.8.3 on both platforms.)
> 
> The program I am running:
> ---✂----------------------------------------------
> import System.IO
> import System.Process
> 
> f =
>   do
>     (  maybeStdinHandel
>      , maybeStdoutHandel
>      , maybeStderrHandel
>      , processHandle
>      ) <- createProcess (proc "cat" ["a.txt"])
>     case maybeStdinHandel of
>       Just stdinHandel ->
>         do
>           putStrLn "stdin"
>       _ -> putStrLn "No stdin handle"
>     case maybeStdoutHandel of
>       Just stdoutHandel ->
>         do
>           putStrLn "stdout"
>           putStrLn =<< hGetContents stdoutHandel
>       _ -> putStrLn "No stdout handle"
>     case maybeStderrHandel of
>       Just stderrHandel ->
>         do
>           putStrLn "stderr"
>           putStrLn =<< hGetContents stderrHandel
>       _ -> putStrLn "No stderr handle"
> 
> main = f
> ---✂----------------------------------------------
> 
> The output:
> ---✂----------------------------------------------
> $ ./ProcessTry
> No stdin handle
> No stdout handle
> No stderr handle
> asdf
> ---✂----------------------------------------------
> (asdf is the contents of file a.txt)
> 
> Regards,
> Henk-Jan van Tuyl
> 
> 



More information about the Haskell-Cafe mailing list