Permalink
Browse files

Add killProcess

  • Loading branch information...
1 parent c4cdd06 commit 1588100655f18bc2811edc0a5911e2b14a1ee411 @timthelion committed Mar 2, 2013
Showing with 20 additions and 0 deletions.
  1. +20 −0 System/Process.hs
View
@@ -61,6 +61,7 @@ module System.Process (
waitForProcess,
getProcessExitCode,
terminateProcess,
+ killProcess,
interruptProcessGroupOf,
#endif
) where
@@ -616,6 +617,20 @@ terminateProcess ph = do
return p_
-- does not close the handle, we might want to try terminating it
-- again, or get its exit code.
+-- ----------------------------------------------------------------------------
+-- killProcess
+
+-- | Sends a kill signal on POSIX systems. Same as terminateProcess on Windows.
+killProcess :: ProcessHandle -> IO ()
+killProcess ph = do
+ withProcessHandle_ ph $ \p_ ->
+ case p_ of
+ ClosedHandle _ -> return p_
+ OpenHandle h -> do
+ throwErrnoIfMinus1Retry_ "killProcess" $ c_killProcess h
+ return p_
+ -- does not close the handle, we might want to try killing it
+ -- again, or get its exit code.
-- ----------------------------------------------------------------------------
-- interruptProcessGroupOf
@@ -692,6 +707,11 @@ foreign import ccall unsafe "terminateProcess"
:: PHANDLE
-> IO CInt
+foreign import ccall unsafe "killProcess"
+ c_killProcess
+ :: PHANDLE
+ -> IO CInt
+
foreign import ccall unsafe "getProcessExitCode"
c_getProcessExitCode
:: PHANDLE

0 comments on commit 1588100

Please sign in to comment.