Commit 0f7b9483 authored by Tamar Christina's avatar Tamar Christina
Browse files

Updated based on review

parent 523b3ddc
......@@ -596,8 +596,8 @@ waitForProcess ph@(ProcessHandle _ delegating_ctlc) = do
throwErrnoIfMinus1Retry_ "waitForProcess" (c_waitForProcess h pret)
modifyProcessHandle ph $ \p_' ->
case p_' of
ClosedHandle e -> return (p_',e)
OpenExtHandle{} -> error "waitForProcess handle mismatch."
ClosedHandle e -> return (p_', e)
OpenExtHandle{} -> return (p_', ExitFailure (-1))
OpenHandle ph' -> do
closePHANDLE ph'
code <- peek pret
......@@ -608,13 +608,13 @@ waitForProcess ph@(ProcessHandle _ delegating_ctlc) = do
when delegating_ctlc $
endDelegateControlC e
return e
OpenExtHandle _ job iocp -> do
OpenExtHandle _ job iocp ->
#if defined(WINDOWS)
maybe (ExitFailure (-1)) mkExitCode `fmap` waitForJobCompletion job iocp timeout_Infinite
where mkExitCode code | code == 0 = ExitSuccess
| otherwise = ExitFailure $ fromIntegral code
#else
error "OpenExtHandle should not happen on POSIX."
return $ ExitFailure (-1)
#endif
-- ----------------------------------------------------------------------------
......@@ -635,14 +635,14 @@ getProcessExitCode ph@(ProcessHandle _ delegating_ctlc) = do
case p_ of
ClosedHandle e -> return (p_, (Just e, False))
open -> do
let h = getHandle open
alloca $ \pExitCode -> do
res <- throwErrnoIfMinus1Retry "getProcessExitCode" $
c_getProcessExitCode h pExitCode
code <- peek pExitCode
res <- let getCode h = throwErrnoIfMinus1Retry "getProcessExitCode" $
c_getProcessExitCode h pExitCode
in maybe (return 0) getCode $ getHandle open
if res == 0
then return (p_, (Nothing, False))
else do
code <- peek pExitCode
closePHANDLE h
let e | code == 0 = ExitSuccess
| otherwise = ExitFailure (fromIntegral code)
......@@ -651,10 +651,10 @@ getProcessExitCode ph@(ProcessHandle _ delegating_ctlc) = do
Just e | was_open && delegating_ctlc -> endDelegateControlC e
_ -> return ()
return m_e
where getHandle :: ProcessHandle__ -> PHANDLE
getHandle (OpenHandle h) = h
getHandle (ClosedHandle _) = error "getHandle: handle closed."
getHandle (OpenExtHandle h _ _) = h
where getHandle :: ProcessHandle__ -> Maybe PHANDLE
getHandle (OpenHandle h) = Just h
getHandle (ClosedHandle _) = Nothing
getHandle (OpenExtHandle h _ _) = Just h
-- ----------------------------------------------------------------------------
......
......@@ -101,11 +101,11 @@ data CreateProcess = CreateProcess{
--
-- @since 1.4.0.0
use_process_jobs :: Bool -- ^ On Windows systems this flag indicates that we should wait for the entire process tree
-- to finish before unblocking. On POSIX system this flag is ignored.
-- to finish before unblocking. On POSIX systems this flag is ignored.
--
-- Default: @False@
--
-- @since 1.x.x.x
-- @since 1.5.0.0
} deriving (Show, Eq)
-- | contains the handles returned by a call to createProcess_Internal
......
......@@ -32,13 +32,13 @@ module System.Process.Internals (
endDelegateControlC,
stopDelegateControlC,
unwrapHandles,
#ifndef WINDOWS
pPrPr_disableITimers, c_execvpe,
ignoreSignal, defaultSignal,
#else
#ifdef WINDOWS
terminateJob,
waitForJobCompletion,
timeout_Infinite,
#else
pPrPr_disableITimers, c_execvpe,
ignoreSignal, defaultSignal,
#endif
withFilePathException, withCEnvironment,
translate,
......@@ -70,7 +70,7 @@ import System.Process.Posix
-- * This function takes an extra @String@ argument to be used in creating
-- error messages.
--
-- * 'use_process_jobs' can set in CreateProcess since 1.4.?.? in order to create
-- * 'use_process_jobs' can be set in CreateProcess since 1.5.0.0 in order to create
-- an I/O completion port to monitor a process tree's progress on Windows.
--
-- The function also returns two new handles:
......
......@@ -44,17 +44,10 @@ import System.Win32.Process (getProcessId)
-- The double hash is used so that hsc does not process this include file
##include "processFlags.h"
#include "windows_cconv.h"
#include <fcntl.h> /* for _O_BINARY */
##if defined(i386_HOST_ARCH)
## define WINDOWS_CCONV stdcall
##elif defined(x86_64_HOST_ARCH)
## define WINDOWS_CCONV ccall
##else
## error Unknown mingw32 arch
##endif
throwErrnoIfBadPHandle :: String -> IO PHANDLE -> IO PHANDLE
throwErrnoIfBadPHandle = throwErrnoIfNull
......
......@@ -5,13 +5,13 @@
* Bug fix: Don't close already closed pipes
[#81](https://github.com/haskell/process/pull/81)
* Relax version bounds of Win32 to allow 2.5.
* Add support for monitoring process tree for termination with the parameter `use_process_jobs`
in `CreateProcess` on Windows. Also added a function `terminateJob` to kill entire process tree.
## 1.4.3.0 *December 2016*
* New exposed `withCreateProcess`
* Derive `Show` and `Eq` for `CreateProcess`, `CmdSpec`, and `StdStream`
* Add support for monitoring process tree for termination with the parameter `use_process_jobs`
in `CreateProcess` on Windows. Also added a function `terminateJob` to kill entire process tree.
## 1.4.2.0 *January 2016*
......
name: process
version: 1.4.3.1
version: 1.5.0.0
-- NOTE: Don't forget to update ./changelog.md
license: BSD3
license-file: LICENSE
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment