From 1c72e0709b767ddd55192617ff7f3dbda9a92cfd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 19 May 2013 15:52:22 -0400 Subject: [PATCH] Fix a zombie that could result when running a process like gpg to read and write to it. --- Utility/Process.hs | 7 ++++--- debian/changelog | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Utility/Process.hs b/Utility/Process.hs index 6e0aef21c6..cee7276562 100644 --- a/Utility/Process.hs +++ b/Utility/Process.hs @@ -47,6 +47,7 @@ import System.Posix.IO #endif import Utility.Misc +import Utility.Exception type CreateProcessRunner = forall a. CreateProcess -> ((Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> IO a) -> IO a @@ -141,13 +142,13 @@ createProcessSuccess :: CreateProcessRunner createProcessSuccess p a = createProcessChecked (forceSuccessProcess p) p a {- Runs createProcess, then an action on its handles, and then - - an action on its exit code. -} + - a checker action on its exit code, which must wait for the process. -} createProcessChecked :: (ProcessHandle -> IO b) -> CreateProcessRunner createProcessChecked checker p a = do t@(_, _, _, pid) <- createProcess p - r <- a t + r <- tryNonAsync $ a t _ <- checker pid - return r + either E.throw return r {- Leaves the process running, suitable for lazy streaming. - Note: Zombies will result, and must be waited on. -} diff --git a/debian/changelog b/debian/changelog index 9ee201ab0c..43bb13c141 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ git-annex (4.20130517) UNRELEASED; urgency=low Closes: #708619 * Switch to MonadCatchIO-transformers for better handling of state while catching exceptions. + * Fix a zombie that could result when running a process like gpg to + read and write to it. -- Joey Hess Fri, 17 May 2013 11:17:03 -0400