snoyberg / conduit

A streaming data library
895 stars 194 forks source link

CP.sourceProcessWithStreams with stdin will raise exception if process ends #420

Open luispedro opened 5 years ago

luispedro commented 5 years ago

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).

snoyberg commented 5 years ago

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