Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haskell System.Process.createProcess redirect stdout and stderr

Tags:

io

unix

haskell

How can I redirect std_in and std_err to a file using createProcess in System.Process?

like image 678
Bilal Syed Hussain Avatar asked Sep 24 '26 03:09

Bilal Syed Hussain


1 Answers

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
like image 52
Daniel Wagner Avatar answered Sep 25 '26 20:09

Daniel Wagner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!