aboutsummaryrefslogtreecommitdiff
path: root/Utility/Process.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-19 15:52:22 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-19 15:52:22 -0400
commitd41405d7db435a65783178a8a31cc7f4b7f19023 (patch)
tree55d5b5f03f4c58702a27c0bf451ce92c027040b5 /Utility/Process.hs
parent482708643b9c2925f9054a63e51048ed8d5d9aa6 (diff)
Fix a zombie that could result when running a process like gpg to read and write to it.
Diffstat (limited to 'Utility/Process.hs')
-rw-r--r--Utility/Process.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/Utility/Process.hs b/Utility/Process.hs
index 6e0aef21c..cee727656 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. -}