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 86e638567a
,
to try the other way to implement it, which will hopefully avoid the problem.
This commit is contained in:
parent
e696b086dc
commit
839ec7e26c
3 changed files with 13 additions and 15 deletions
|
@ -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 ()
|
||||
|
|
10
Utility/winprocess.c
Normal file
10
Utility/winprocess.c
Normal file
|
@ -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);
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue