[commit: packages/process] master: Updated based on review (0f7b948)
git at git.haskell.org
git at git.haskell.org
Wed Jul 19 21:18:52 UTC 2017
Repository : ssh://git@git.haskell.org/process
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/0f7b9483a11a51bd8f2941f590f22b5f91fb1df7/process
>---------------------------------------------------------------
commit 0f7b9483a11a51bd8f2941f590f22b5f91fb1df7
Author: Tamar Christina <tamar at zhox.com>
Date: Sun Jan 29 20:52:53 2017 +0000
Updated based on review
>---------------------------------------------------------------
0f7b9483a11a51bd8f2941f590f22b5f91fb1df7
System/Process.hs | 24 ++++++++++++------------
System/Process/Common.hs | 4 ++--
System/Process/Internals.hs | 10 +++++-----
System/Process/Windows.hsc | 9 +--------
changelog.md | 4 ++--
process.cabal | 2 +-
6 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/System/Process.hs b/System/Process.hs
index a0574e4..53c1f21 100644
--- a/System/Process.hs
+++ b/System/Process.hs
@@ -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
-- ----------------------------------------------------------------------------
diff --git a/System/Process/Common.hs b/System/Process/Common.hs
index 0f70f7a..b2caae6 100644
--- a/System/Process/Common.hs
+++ b/System/Process/Common.hs
@@ -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
diff --git a/System/Process/Internals.hs b/System/Process/Internals.hs
index 026cd99..036e1c0 100644
--- a/System/Process/Internals.hs
+++ b/System/Process/Internals.hs
@@ -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:
diff --git a/System/Process/Windows.hsc b/System/Process/Windows.hsc
index ff8d3a7..07c4f0d 100644
--- a/System/Process/Windows.hsc
+++ b/System/Process/Windows.hsc
@@ -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
diff --git a/changelog.md b/changelog.md
index 991be99..bee8874 100644
--- a/changelog.md
+++ b/changelog.md
@@ -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*
diff --git a/process.cabal b/process.cabal
index b339938..0ef5b91 100644
--- a/process.cabal
+++ b/process.cabal
@@ -1,5 +1,5 @@
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
More information about the ghc-commits
mailing list