make withQuietOutput work on Windows

This commit is contained in:
Joey Hess 2013-06-17 21:26:06 -04:00
parent 9ef09587dc
commit 287fb00163

View file

@ -241,12 +241,18 @@ withQuietOutput
:: CreateProcessRunner :: CreateProcessRunner
-> CreateProcess -> CreateProcess
-> IO () -> IO ()
withQuietOutput creator p = withFile "/dev/null" WriteMode $ \devnull -> do withQuietOutput creator p = withFile devnull WriteMode $ \nullh -> do
let p' = p let p' = p
{ std_out = UseHandle devnull { std_out = UseHandle nullh
, std_err = UseHandle devnull , std_err = UseHandle nullh
} }
creator p' $ const $ return () creator p' $ const $ return ()
where
#ifndef mingw32_HOST_OS
devnull = "/dev/null"
#else
devnull = "NUL"
#endif
{- Extract a desired handle from createProcess's tuple. {- Extract a desired handle from createProcess's tuple.
- These partial functions are safe as long as createProcess is run - These partial functions are safe as long as createProcess is run