Use ProcessHandle in withServer to allow kill it by client code
[lsp-test.git] / src / Language / Haskell / LSP / Test / Server.hs
index 5449dfbbf40317aae94ba65a17ef9d169dc08a6b..0a77a6193e6fb9c320531e65f74255576bccf8f4 100644 (file)
@@ -2,11 +2,10 @@ module Language.Haskell.LSP.Test.Server (withServer) where
 
 import Control.Concurrent.Async
 import Control.Monad
-import Language.Haskell.LSP.Test.Compat
 import System.IO
 import System.Process
 
-withServer :: String -> Bool -> (Handle -> Handle -> Int -> IO a) -> IO a
+withServer :: String -> Bool -> (Handle -> Handle -> ProcessHandle -> IO a) -> IO a
 withServer serverExe logStdErr f = do
   -- TODO Probably should just change runServer to accept
   -- separate command and arguments
@@ -19,5 +18,4 @@ withServer serverExe logStdErr f = do
     hSetBinaryMode serverErr True
     let errSinkThread = forever $ hGetLine serverErr >>= when logStdErr . putStrLn
     withAsync errSinkThread $ \_ -> do
-      pid <- getProcessID serverProc
-      f serverIn serverOut pid
+      f serverIn serverOut serverProc