diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs index cfac8794c4..31f6cfc693 100644 --- a/Utility/WinProcess.hs +++ b/Utility/WinProcess.hs @@ -11,5 +11,18 @@ module Utility.WinProcess where import Utility.PID -foreign import ccall unsafe "winprocess.h terminatepid" - terminatePID :: PID -> IO () +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 diff --git a/Utility/winprocess.c b/Utility/winprocess.c deleted file mode 100644 index b6e3155739..0000000000 --- a/Utility/winprocess.c +++ /dev/null @@ -1,10 +0,0 @@ -#include - -void terminatepid (DWORD pid) { - HANDLE h; - h = OpenProcess(PROCESS_TERMINATE, 0, pid); - if (h != NULL) { - TerminateProcess(h, 1); - } - CloseHandle(h); -} diff --git a/Utility/winprocess.h b/Utility/winprocess.h deleted file mode 100644 index eac954fcae..0000000000 --- a/Utility/winprocess.h +++ /dev/null @@ -1,3 +0,0 @@ -#include - -void terminatepid (DWORD pid); diff --git a/git-annex.cabal b/git-annex.cabal index 780d66a1ea..4115b5ba6a 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -1062,8 +1062,6 @@ Executable git-annex Utility.LockFile.Windows Utility.LockPool.Windows Utility.WinProcess - C-Sources: Utility/winprocess.c - Includes: Utility/winprocess.h else Other-Modules: Utility.LockFile.Posix