port transferkeys to windows; make stopping in progress transfers work too (probably)
transferkeys had used special FDs for communication, but that would be quite annoying to do in Windows. Instead, use stdin and stdout. But, to avoid commands like rsync stomping on them and messing up the communications channel, they're duplicated to a different handle; stdin is replaced with a null handle, and stdout is replaced with a copy of stderr. This should all work in windows too. Stopping in progress transfers may work on windows.. if the types unify anyway. ;) May need some more porting.
This commit is contained in:
parent
0fbbe79d8f
commit
2fd63f3cfa
6 changed files with 51 additions and 79 deletions
|
@ -26,12 +26,12 @@ module Utility.Process (
|
|||
withHandle,
|
||||
withBothHandles,
|
||||
withQuietOutput,
|
||||
withNullHandle,
|
||||
createProcess,
|
||||
startInteractiveProcess,
|
||||
stdinHandle,
|
||||
stdoutHandle,
|
||||
stderrHandle,
|
||||
devNull,
|
||||
) where
|
||||
|
||||
import qualified System.Process
|
||||
|
@ -280,20 +280,18 @@ withQuietOutput
|
|||
:: CreateProcessRunner
|
||||
-> CreateProcess
|
||||
-> IO ()
|
||||
withQuietOutput creator p = withNullHandle $ \nullh -> do
|
||||
withQuietOutput creator p = withFile devNull WriteMode $ \nullh -> do
|
||||
let p' = p
|
||||
{ std_out = UseHandle nullh
|
||||
, std_err = UseHandle nullh
|
||||
}
|
||||
creator p' $ const $ return ()
|
||||
|
||||
withNullHandle :: (Handle -> IO a) -> IO a
|
||||
withNullHandle = withFile devnull WriteMode
|
||||
where
|
||||
devNull :: FilePath
|
||||
#ifndef mingw32_HOST_OS
|
||||
devnull = "/dev/null"
|
||||
devNull = "/dev/null"
|
||||
#else
|
||||
devnull = "NUL"
|
||||
devNull = "NUL"
|
||||
#endif
|
||||
|
||||
{- Extract a desired handle from createProcess's tuple.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue