For some time I’ve used this little utility to run a command with parameters and return stdout if the command exited successfully, or stdout and stderr if there was an error:
Unfortunately this code is prone to deadlocking – I had this happen on a call to dcm2mnc. It ran dcm2mnc and then hung.
The fix was to use process-streaming which provides a wrapper for createProcess:
And it’s straightforward to use it to get the stdout and stderr separately:
Here’s my commit where I switched to process-streaming: https://github.com/carlohamalainen/mytardis-rest/commit/7a97d2482abc7e5726ed003a480fc9a27ead7403.
A discussion on haskell-cafe where I found out about process-streaming: https://groups.google.com/d/msg/haskell-cafe/I1ROxgw7DIs/taKHeJJHiVkJ.