Closed joeyh closed 7 years ago
There currently seems to be no way to use this library to terminate an arbitrary process by ProcessID.
Some code that has worked for me to do this in the past is this:
import System.Win32.Process import Control.Exception (bracket) import Control.Monad terminateProcess :: ProcessID -> IO () terminateProcess 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
Might want to call it terminateProcessID instead to avoid name conflict with System.Process.terminateProcess
There currently seems to be no way to use this library to terminate an arbitrary process by ProcessID.
Some code that has worked for me to do this in the past is this: