From 0284bfbec393b0d1f74ebbb935e331029dc21c73 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 3 Feb 2022 13:52:34 +0100 Subject: [PATCH] Use Process.withCreateProcess to ensure child cleanup --- Cabal/src/Distribution/Simple/Utils.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Cabal/src/Distribution/Simple/Utils.hs b/Cabal/src/Distribution/Simple/Utils.hs index 1772bfac096..8ad4fc3119e 100644 --- a/Cabal/src/Distribution/Simple/Utils.hs +++ b/Cabal/src/Distribution/Simple/Utils.hs @@ -789,9 +789,10 @@ rawSystemProcAction :: Verbosity -> Process.CreateProcess -> IO (ExitCode, a) rawSystemProcAction verbosity cp action = withFrozenCallStack $ do logCommand verbosity cp - (mStdin, mStdout, mStderr, p) <- Process.createProcess cp - a <- action mStdin mStdout mStderr - exitcode <- Process.waitForProcess p + (exitcode, a) <- Process.withCreateProcess cp $ \mStdin mStdout mStderr p -> do + a <- action mStdin mStdout mStderr + exitcode <- Process.waitForProcess p + return (exitcode, a) unless (exitcode == ExitSuccess) $ do let cmd = case Process.cmdspec cp of Process.ShellCommand sh -> sh