packages feed

typed-process 0.2.4.0 → 0.2.4.1

raw patch · 4 files changed

+41/−39 lines, 4 filesdep ~asyncdep ~bytestringdep ~stmPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: async, bytestring, stm

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.2.4.1++* Fix a `Handle` leak in `withProcessInterleave` and its derivatives.+ ## 0.2.4.0  * Add `readProcessInterleaved` and `readProcessInterleaved_` to support
README.md view
@@ -29,7 +29,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.IO (hPutStr, hClose) import System.Process.Typed@@ -85,7 +85,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -113,7 +113,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -129,7 +129,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -157,7 +157,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -189,7 +189,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -220,7 +220,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -234,7 +234,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -247,7 +247,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -265,7 +265,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.Exit (ExitCode)@@ -291,7 +291,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import Data.ByteString.Lazy (ByteString)@@ -312,12 +312,12 @@ from a process to a file. This is superior to the memory approach as it does not have the risk of using large amounts of memory, though it is more inconvenient. Together with the-[`UnliftIO.Temporary`](https://www.stackage.org/haddock/lts-10.2/unliftio-0.2.2.0/UnliftIO-Temporary.html), we+[`UnliftIO.Temporary`](https://www.stackage.org/haddock/lts/unliftio/UnliftIO-Temporary.html), we can do some nice things:  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import UnliftIO.Temporary (withSystemTempFile)@@ -341,7 +341,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO (hClose)@@ -371,7 +371,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -383,7 +383,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -396,7 +396,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO@@ -422,7 +422,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO@@ -456,7 +456,7 @@  ```haskell #!/usr/bin/env stack--- stack --resolver lts-10.2 script+-- stack --resolver lts-12.21 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed 
src/System/Process/Typed.hs view
@@ -3,7 +3,6 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE DataKinds #-}-{-# LANGUAGE KindSignatures #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE ScopedTypeVariables #-} -- | Please see the README.md file for examples of using this API.@@ -507,7 +506,7 @@ #if MIN_VERSION_process(1, 4, 0) closed = mkStreamSpec P.NoStream (\_ Nothing -> pure ((), return ())) #else-closed = mkStreamSpec P.CreatePipe (\_ (Just h) -> (((), return ()) <$ hClose h))+closed = mkStreamSpec P.CreatePipe (\_ (Just h) -> ((), return ()) <$ hClose h) #endif  -- | An input stream spec which sets the input to the given@@ -636,7 +635,7 @@           if multiThreadedRuntime             then P.waitForProcess pHandle             else do-              switchTime <- (fromIntegral . (`div` 1000) . ctxtSwitchTime)+              switchTime <- fromIntegral . (`div` 1000) . ctxtSwitchTime                         <$> getConcFlags               let minDelay = 1                   maxDelay = max minDelay switchTime@@ -849,21 +848,20 @@   :: ProcessConfig stdin stdoutIgnored stderrIgnored   -> (Process stdin (STM L.ByteString) () -> IO a)   -> IO a-withProcessInterleave pc inner = do+withProcessInterleave pc inner =     -- Create a pipe to be shared for both stdout and stderr-    (readEnd, writeEnd) <- P.createPipe--    -- Use the writer end of the pipe for both stdout and stderr. For-    -- the stdout half, use byteStringFromHandle to read the data into-    -- a lazy ByteString in memory.-    let pc' = setStdout (mkStreamSpec (P.UseHandle writeEnd) (\pc'' Nothing -> byteStringFromHandle pc'' readEnd))-            $ setStderr (useHandleOpen writeEnd)-              pc-    withProcess pc' $ \p -> do-      -- Now that the process is forked, close the writer end of this-      -- pipe, otherwise the reader end will never give an EOF.-      hClose writeEnd-      inner p+    bracket P.createPipe (\(r, w) -> hClose r >> hClose w) $ \(readEnd, writeEnd) -> do+        -- Use the writer end of the pipe for both stdout and stderr. For+        -- the stdout half, use byteStringFromHandle to read the data into+        -- a lazy ByteString in memory.+        let pc' = setStdout (mkStreamSpec (P.UseHandle writeEnd) (\pc'' Nothing -> byteStringFromHandle pc'' readEnd))+                $ setStderr (useHandleOpen writeEnd)+                  pc+        withProcess pc' $ \p -> do+          -- Now that the process is forked, close the writer end of this+          -- pipe, otherwise the reader end will never give an EOF.+          hClose writeEnd+          inner p  -- | Same as 'readProcess', but interleaves stderr with stdout. --@@ -891,7 +889,7 @@   => ProcessConfig stdin stdoutIgnored stderrIgnored   -> m L.ByteString readProcessInterleaved_ pc =-    liftIO $ do+    liftIO $     withProcessInterleave pc $ \p -> atomically $ do       stdout' <- getStdout p       checkExitCodeSTM p `catchSTM` \ece -> throwSTM ece
typed-process.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 11c70077cb1b56f53730fd5ab768dd6b89dd6c3850649afb4cae269796982aff+-- hash: 377b4644a4d63eb0b81f60f4e7ec4b477eae658e463f90a600c923053da58712  name:           typed-process-version:        0.2.4.0+version:        0.2.4.1 synopsis:       Run external processes, with strong typing of streams description:    Please see the tutorial at <https://haskell-lang.org/library/typed-process> category:       System