diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-09-01 14:37:02 -0700 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-09-01 14:51:14 -0700 |
commit | 6d66a81ca98f8579bf06f7fb724ed733670d39b9 (patch) | |
tree | 1acad0170e35d49cc6ff732fbf539648de7073e7 /Utility | |
parent | 6e4a1f7a771ca10ede528776ed126ef11f802dfd (diff) |
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
4f59f9439687cccfb7aac6aca62dbe97038179bf I mention having tried this
approach before, and getting segfaults.. So, who knows. It seems to work
fine with ghc 7.10 at least.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/WinProcess.hs | 17 | ||||
-rw-r--r-- | Utility/winprocess.c | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs index 36f079d04..31f6cfc69 100644 --- a/Utility/WinProcess.hs +++ b/Utility/WinProcess.hs @@ -11,5 +11,18 @@ module Utility.WinProcess where import Utility.PID -foreign import ccall unsafe "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 b6e315573..000000000 --- a/Utility/winprocess.c +++ /dev/null @@ -1,10 +0,0 @@ -#include <windows.h> - -void terminatepid (DWORD pid) { - HANDLE h; - h = OpenProcess(PROCESS_TERMINATE, 0, pid); - if (h != NULL) { - TerminateProcess(h, 1); - } - CloseHandle(h); -} |