conduit icon indicating copy to clipboard operation
conduit copied to clipboard

CP.sourceProcessWithStreams with stdin will raise exception if process ends

Open luispedro opened this issue 5 years ago • 1 comments

I'm not sure if this is a bug or just undocumented behaviour, but the following will raise an exception:

    CP.sourceProcessWithStreams
        (proc "false" [])
        (CC.yieldMany ["Hello", "World"])
        CL.consume
        CL.consume

See full code at Main.hs.txt

Leads to

testing: fd:4: hClose: resource vanished (Broken pipe)

My guess is that the closeStdin call at https://github.com/snoyberg/conduit/blob/1d59ab8cc67b4fe13d2ace3b5122723926cd9ea6/conduit-extra/Data/Conduit/Process.hs#L140 causes the exception to be raised.

My biggest problem is that I don't see a way to get the stderr/stdout of the process to show them to the user as to what failed (see https://github.com/ngless-toolkit/ngless/issues/121).

luispedro avatar Sep 19 '19 15:09 luispedro

I overall recommend using the Typed module, it's more well tested and what I use these days. That said, I'm surprised too see this at all. I thought hClose itself was supposed to protect against double free bugs with an MVar

snoyberg avatar Sep 22 '19 05:09 snoyberg