How can I redirect std_in and std_err to a file using createProcess in System.Process?
Use the std_in and std_err fields of the CreateProcess type:
foo cmd fin ferr =
withFile fin ReadMode $ \hin ->
withFile ferr WriteMode $ \herr -> do
(_, _, _, ph) <- createProcess (proc cmd [])
{ std_in = UseHandle hin
, std_err = UseHandle herr
}
waitForProcess ph
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With