2 -- For some reason ghc warns about not using
3 -- Control.Monad.IO.Class but it's needed for
5 {-# OPTIONS_GHC -Wunused-imports #-}
6 module Language.Haskell.LSP.Test.Compat where
10 #if MIN_VERSION_process(1,6,3)
11 import System.Process hiding (getPid)
12 import qualified System.Process (getPid)
15 import System.Process.Internals
16 import Control.Concurrent.MVar
19 #ifdef mingw32_HOST_OS
20 import qualified System.Win32.Process
22 import qualified System.Posix.Process
26 getCurrentProcessID :: IO Int
27 #ifdef mingw32_HOST_OS
28 getCurrentProcessID = fromIntegral <$> System.Win32.Process.getCurrentProcessId
30 getCurrentProcessID = fromIntegral <$> System.Posix.Process.getProcessID
33 getProcessID :: ProcessHandle -> IO Int
34 getProcessID p = fromIntegral . fromJust <$> getProcessID' p
36 #if MIN_VERSION_process(1,6,3)
37 getProcessID' = System.Process.getPid
39 #if MIN_VERSION_process(1,6,0)
40 getProcessID' (ProcessHandle mh _ _) = do
42 getProcessID' (ProcessHandle mh _) = do
46 #ifdef mingw32_HOST_OS
48 pid <- System.Win32.Process.getProcessId h
51 OpenHandle pid -> return $ Just pid