avoiding depending on latest version of process except on Windows

This commit is contained in:
Joey Hess 2017-04-10 12:14:24 -04:00
parent e05acd20a5
commit 76c63a4a66
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 13 additions and 2 deletions

View file

@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE CPP #-}
module Annex.Multicast where
import Config.Files
@ -14,6 +16,9 @@ import Utility.PartialPrelude
import System.Process
import System.IO
import GHC.IO.Handle.FD
#if ! MIN_VERSION_process(1,4,2)
import System.Posix.IO (handleToFd)
#endif
multicastReceiveEnv :: String
multicastReceiveEnv = "GIT_ANNEX_MULTICAST_RECEIVE"
@ -21,8 +26,14 @@ multicastReceiveEnv = "GIT_ANNEX_MULTICAST_RECEIVE"
multicastCallbackEnv :: IO (FilePath, [(String, String)], Handle)
multicastCallbackEnv = do
gitannex <- readProgramFile
#if MIN_VERSION_process(1,4,2)
-- This will even work on Windows
(rfd, wfd) <- createPipeFd
rh <- fdToHandle rfd
#else
(rh, wh) <- createPipe
wfd <- handleToFd wh
#endif
environ <- addEntry multicastReceiveEnv (show wfd) <$> getEnvironment
return (gitannex, environ, rh)