diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-10-24 13:05:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-10-24 13:05:24 -0400 |
commit | 0eee7a2eb5f3459dbfc9c5b32757e5c866092e6b (patch) | |
tree | 2cb2ed274cfc2f5d8b491fb76f9b8d4ea0488d62 /Utility/WinProcess.hs | |
parent | a6ed08a839f93ddc9d486cf7ca837aea6576f540 (diff) |
Revert "try to avoid TerminateProcess link error on windows"
This reverts commit d6d0b1fe20397bf073f11d579f5c0c38785e071a.
Neither way is working.. The other way failed:
.stack-work\dist\5f9bc736\build\git-annex\git-annex-tmp\Assistant.o:fake:(.text+0x6bb3): undefined reference to `terminatepid'
Seems that winprocess.c is not getting linked in.
Diffstat (limited to 'Utility/WinProcess.hs')
-rw-r--r-- | Utility/WinProcess.hs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/Utility/WinProcess.hs b/Utility/WinProcess.hs index cfac8794c..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 "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 |