Revert "try to avoid TerminateProcess link error on windows"

This reverts commit 839ec7e26c.

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.
This commit is contained in:
Joey Hess 2017-10-24 13:05:24 -04:00
parent bcd394657f
commit 901807cf75
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 15 additions and 17 deletions

View file

@ -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

View file

@ -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);
}

View file

@ -1,3 +0,0 @@
#include <windows.h>
void terminatepid (DWORD pid);

View file

@ -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