blob: 31f6cfc693d0325124656d16a45b3f5682a62542 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
{- Windows processes
-
- Copyright 2014 Joey Hess <id@joeyh.name>
-
- License: BSD-2-clause
-}
{-# LANGUAGE ForeignFunctionInterface #-}
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
|