git-annex/Utility/WinProcess.hs
Joey Hess 86e638567a Fix Windows build to work with ghc 7.10
It was failing at link time, some problem with terminatePID.
Re-implemented that to not use a C wrapper function, which cleared up the
problem. Removed old EvilLinker hack with must have been related to the
same problem.

Note that I have not tested this with older ghc's. In
f11f7520b5 I mention having tried this
approach before, and getting segfaults.. So, who knows. It seems to work
fine with ghc 7.10 at least.
2015-09-01 14:51:14 -07:00

28 lines
651 B
Haskell

{- Windows processes
-
- Copyright 2014 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
{-# LANGUAGE ForeignFunctionInterface #-}
module Utility.WinProcess where
import Utility.PID
import System.Win32.Process
import Control.Exception (bracket)
import Control.Monad
terminatePID :: PID -> IO ()
terminatePID p = bracket
(openProcess pROCESS_TERMINATE False p)
(void . c_closeProcess)
(\h -> void $ c_TerminateProcess h 1)
foreign import ccall unsafe "windows.h TerminateProcess"
c_TerminateProcess :: ProcessHandle -> Int -> IO Int
foreign import ccall unsafe "windows.h CloseHandle"
c_closeProcess :: ProcessHandle -> IO Bool