summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Utility/WinProcess.hs17
-rw-r--r--Utility/winprocess.c10
-rw-r--r--git-annex.cabal1
3 files changed, 13 insertions, 15 deletions
diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs
index 31f6cfc69..36f079d04 100644
--- a/Utility/WinProcess.hs
+++ b/Utility/WinProcess.hs
@@ -11,18 +11,5 @@ 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
+foreign import ccall unsafe "terminatepid"
+ terminatePID :: PID -> IO ()
diff --git a/Utility/winprocess.c b/Utility/winprocess.c
new file mode 100644
index 000000000..b6e315573
--- /dev/null
+++ b/Utility/winprocess.c
@@ -0,0 +1,10 @@
+#include <windows.h>
+
+void terminatepid (DWORD pid) {
+ HANDLE h;
+ h = OpenProcess(PROCESS_TERMINATE, 0, pid);
+ if (h != NULL) {
+ TerminateProcess(h, 1);
+ }
+ CloseHandle(h);
+}
diff --git a/git-annex.cabal b/git-annex.cabal
index 65bf31a08..f332c6f0f 100644
--- a/git-annex.cabal
+++ b/git-annex.cabal
@@ -1061,6 +1061,7 @@ Executable git-annex
Utility.LockFile.Windows
Utility.LockPool.Windows
Utility.WinProcess
+ C-Sources: Utility/winprocess.c
else
Other-Modules:
Utility.LockFile.Posix