summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-10-24 12:33:44 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-10-24 12:33:44 -0400
commitd6d0b1fe20397bf073f11d579f5c0c38785e071a (patch)
treed164807d5d29452b0a9f6e0f1b62890418fa3281 /Utility
parentd004d771b88d8aff901304ab093d7396ed476b2f (diff)
try to avoid TerminateProcess link error on windows
Building with stack, it failed: `_TerminateProcess' referenced in section `.text' of .stack-work\dist\5f9bc736\build\git-annex\git-annex-tmp\Utility\WinProcess.o: defined in discarded section `.text' of C:/Users/jenkins/AppData/Local/Programs/stack/i386-windows/ghc-8.0.2/mingw/bin/../lib/gcc/i686-w64-mingw32/5.2.0/../../../../i686-w64-mingw32/lib/../lib/libkernel32.a(dacgs01154.o) This is a reversion of 6d66a81ca98f8579bf06f7fb724ed733670d39b9, to try the other way to implement it, which will hopefully avoid the problem.
Diffstat (limited to 'Utility')
-rw-r--r--Utility/WinProcess.hs17
-rw-r--r--Utility/winprocess.c10
2 files changed, 12 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);
+}