packages feed

process-conduit 0.5.0.1 → 0.5.0.2

raw patch · 3 files changed

+18/−14 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Data/Conduit/Process.hs view
@@ -26,7 +26,7 @@ import Data.Conduit
 import qualified Data.Conduit.List as CL
 import Data.Maybe
-import System.Exit
+import System.Exit (ExitCode(..))
 import System.IO
 import System.Process
 
@@ -41,7 +41,7 @@ conduitProcess cp = do
   (_, (Just cin, Just cout, _, ph)) <- lift $ allocate createp closep
 
-  repeatLoopT $ do
+  end <- repeatLoopT $ do
     -- if process's outputs are available, then yields them.
     repeatLoopT $ do
       b <- liftIO $ hReady' cout
@@ -51,11 +51,11 @@ 
     -- if process exited, then exit
     end <- liftIO $ getProcessExitCode ph
-    when (isJust end) exit
+    when (isJust end) $ exitWith end
 
     -- if upper stream ended, then exit
     inp <- lift await
-    when (isNothing inp) exit
+    when (isNothing inp) $ exitWith Nothing
 
     -- put input to process
     liftIO $ S.hPut cin $ fromJust inp
@@ -68,7 +68,8 @@     out <- liftIO $ S.hGetSome cout bufSize
     when (S.null out) exit
     lift $ yield out
-  ec <- liftIO $ waitForProcess ph
+
+  ec <- liftIO $ maybe (waitForProcess' ph) return end
   lift $ when (ec /= ExitSuccess) $ monadThrow ec
 
   where
@@ -83,7 +84,10 @@       _ <- waitForProcess ph
       return ()
 
-    hReady' h = hReady h `E.catch` \(E.SomeException _) -> return False
+    hReady' h =
+      hReady h `E.catch` \(E.SomeException _) -> return False
+    waitForProcess' ph =
+      waitForProcess ph `E.catch` \(E.SomeException _) -> return ExitSuccess
 
 -- | Source of process
 sourceProcess :: MonadResource m => CreateProcess -> GSource m S.ByteString
README.md view
@@ -1,5 +1,5 @@ process-conduit: Conduit for processes-===============================================+======================================  # About @@ -28,8 +28,8 @@ but execution will perform strictly.  The result type of `scmd` and `ccmd` are-`Source ByteString m ByteString` and-`Conduit ByteString m ByteString` respectively.+`GSource m ByteString` and+`GConduit ByteString m ByteString` respectively.  If a command is failed, an exception is thrown. @@ -40,14 +40,14 @@ * Create a Source and a Conduit of process  ~~~ {.haskell}-import qualified Data.Conduit as C+import Data.Conduit import qualified Data.Conduit.Binary as CB import Data.Conduit.Process import System.IO  main :: IO ()-main = C.runResourceT $ do-  sourceCmd "ls" C.$= conduitCmd "sort" C.$$ CB.sinkHandle stdout+main = runResourceT $ do+  sourceCmd "ls" $= conduitCmd "sort" $$ CB.sinkHandle stdout ~~~  * Invoke a process simply@@ -64,7 +64,7 @@ ~~~ {.haskell} main :: IO () main = runResourceT $ do-  [scmd|ls|] $= [ccmd|sort|] $$ sinkHandle stdout+  [scmd|ls|] $= [ccmd|sort|] $$ CB.sinkHandle stdout ~~~  * Unquoting (syntax is same as [shakespeare-text](http://hackage.haskell.org/package/shakespeare-text))
process-conduit.cabal view
@@ -1,5 +1,5 @@ name:                process-conduit-version:             0.5.0.1+version:             0.5.0.2 synopsis:            Conduits for processes  description: