windows: Fix process termination code.
The ctrl-c hack used before didn't actually seem to work. No haskell libraries expose TerminateProcess. I tried just calling it via FFI, but got segfaults, probably to do with the wacky process handle not being managed correctly. Moving it all into one C function worked. This was hell. The EvilLinker hack was just final icing on the cake. We all know what the cake was made of.
This commit is contained in:
parent
84083ecdd3
commit
f11f7520b5
10 changed files with 58 additions and 24 deletions
|
@ -13,14 +13,13 @@ import Common
|
|||
import Utility.PID
|
||||
#ifndef mingw32_HOST_OS
|
||||
import Utility.LogFile
|
||||
#else
|
||||
import Utility.WinProcess
|
||||
#endif
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
import System.Posix
|
||||
import Control.Concurrent.Async
|
||||
#else
|
||||
import System.PosixCompat.Types
|
||||
import System.Win32.Console (generateConsoleCtrlEvent, cTRL_C_EVENT)
|
||||
#endif
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
|
@ -75,7 +74,7 @@ lockPidFile file = do
|
|||
_ <- fdWrite fd' =<< show <$> getPID
|
||||
closeFd fd
|
||||
#else
|
||||
writeFile newfile "-1"
|
||||
writeFile newfile . show =<< getPID
|
||||
#endif
|
||||
rename newfile file
|
||||
where
|
||||
|
@ -121,5 +120,5 @@ stopDaemon pidfile = go =<< checkDaemon pidfile
|
|||
#ifndef mingw32_HOST_OS
|
||||
signalProcess sigTERM pid
|
||||
#else
|
||||
generateConsoleCtrlEvent cTRL_C_EVENT pid
|
||||
terminatePID pid
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue