Hello community, here is the log from the commit of package ghc-typed-process for openSUSE:Factory checked in at 2018-05-30 12:15:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-typed-process (Old) and /work/SRC/openSUSE:Factory/.ghc-typed-process.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-typed-process" Wed May 30 12:15:07 2018 rev:3 rq:607912 version:0.2.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-typed-process/ghc-typed-process.changes 2017-04-12 18:09:43.333053508 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-typed-process.new/ghc-typed-process.changes 2018-05-30 12:27:43.233411722 +0200 @@ -1,0 +2,13 @@ +Mon May 14 17:02:11 UTC 2018 - psim...@suse.com + +- Update typed-process to version 0.2.2.0. + * Add inherit versions of setter functions + * Add `readProcessStdout`, `readProcessStdout_`, `readProcessStderr`, and `readProcessStderr_` + * Do not show modified environment information in exceptions + * Remove dependency on `conduit` and `conduit-extra`. Relevant code added to + `Data.Conduit.Process.Typed` in `conduit-extra-1.2.1`. + * Introduce 'unsafeProcessHandle' function + * Fix bug in `waitForProcess` that caused exit code to be lost + * Minor doc improvements + +------------------------------------------------------------------- Old: ---- typed-process-0.1.0.0.tar.gz New: ---- typed-process-0.2.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-typed-process.spec ++++++ --- /var/tmp/diff_new_pack.ezncdX/_old 2018-05-30 12:27:44.097381429 +0200 +++ /var/tmp/diff_new_pack.ezncdX/_new 2018-05-30 12:27:44.097381429 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-typed-process # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,37 +19,32 @@ %global pkg_name typed-process %bcond_with tests Name: ghc-%{pkg_name} -Version: 0.1.0.0 +Version: 0.2.2.0 Release: 0 Summary: Run external processes, with strong typing of streams License: MIT -Group: Development/Languages/Other -Url: https://hackage.haskell.org/package/%{pkg_name} +Group: Development/Libraries/Haskell +URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel BuildRequires: ghc-async-devel BuildRequires: ghc-bytestring-devel -BuildRequires: ghc-conduit-devel -BuildRequires: ghc-conduit-extra-devel -BuildRequires: ghc-exceptions-devel BuildRequires: ghc-process-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-stm-devel BuildRequires: ghc-transformers-devel -BuildRoot: %{_tmppath}/%{name}-%{version}-build %if %{with tests} BuildRequires: ghc-base64-bytestring-devel BuildRequires: ghc-hspec-devel -BuildRequires: ghc-http-conduit-devel BuildRequires: ghc-temporary-devel %endif %description -Run external processes, with strong typing of streams. +Please see the tutorial at <https://haskell-lang.org/library/typed-process>. %package devel Summary: Haskell %{pkg_name} library development files -Group: Development/Libraries/Other +Group: Development/Libraries/Haskell Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} @@ -77,11 +72,9 @@ %ghc_pkg_recache %files -f %{name}.files -%defattr(-,root,root,-) -%doc LICENSE +%license LICENSE %files devel -f %{name}-devel.files -%defattr(-,root,root,-) %doc ChangeLog.md README.md %changelog ++++++ typed-process-0.1.0.0.tar.gz -> typed-process-0.2.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typed-process-0.1.0.0/ChangeLog.md new/typed-process-0.2.2.0/ChangeLog.md --- old/typed-process-0.1.0.0/ChangeLog.md 2016-10-21 07:46:42.000000000 +0200 +++ new/typed-process-0.2.2.0/ChangeLog.md 2018-03-19 13:38:53.000000000 +0100 @@ -1,3 +1,26 @@ +## 0.2.2.0 + +* Add inherit versions of setter functions + +## 0.2.1.0 + +* Add `readProcessStdout`, `readProcessStdout_`, `readProcessStderr`, and `readProcessStderr_` +* Do not show modified environment information in exceptions + +## 0.2.0.0 + +* Remove dependency on `conduit` and `conduit-extra`. Relevant code added to + `Data.Conduit.Process.Typed` in `conduit-extra-1.2.1`. + +## 0.1.1 + +* Introduce 'unsafeProcessHandle' function + +## 0.1.0.1 + +* Fix bug in `waitForProcess` that caused exit code to be lost +* Minor doc improvements + ## 0.1.0.0 * Initial commit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typed-process-0.1.0.0/README.md new/typed-process-0.2.2.0/README.md --- old/typed-process-0.1.0.0/README.md 2016-10-21 07:46:42.000000000 +0200 +++ new/typed-process-0.2.2.0/README.md 2018-03-19 13:34:42.000000000 +0100 @@ -2,6 +2,9 @@ [![Build Status](https://travis-ci.org/fpco/typed-process.svg?branch=master)](https://travis-ci.org/fpco/typed-process) [![Build status](https://ci.appveyor.com/api/projects/status/bhh7aekbgeqp7g5j/branch/master?svg=true)](https://ci.appveyor.com/project/snoyberg/typed-process/branch/master) +API level documentation (Haddocks) may be [found on +Stackage](https://www.stackage.org/package/typed-process). + This library provides the ability to launch and interact with external processes. It wraps around the [process library](https://haskell-lang.org/library/process), and @@ -20,7 +23,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.IO (hPutStr, hClose) import System.Process.Typed @@ -76,7 +79,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -104,7 +107,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -120,7 +123,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -135,8 +138,8 @@ ## Type parameters -Both `ProcessConfig` and `Process` each take three type parameters, -with the type of the standard input, output, and error streams for the +Both `ProcessConfig` and `Process` take three type parameters: +the types of the standard input, output, and error streams for the process. As you saw above, our default is `()` for each, and our default behavior is to inherit the streams from the parent process. This is why, when you run the previous programs, the `date` @@ -148,7 +151,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -180,7 +183,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -211,7 +214,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -225,7 +228,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -238,7 +241,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -256,7 +259,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.Exit (ExitCode) @@ -282,7 +285,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import Data.ByteString.Lazy (ByteString) @@ -303,15 +306,15 @@ 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 -[temporary library](https://www.stackage.org/package/temporary), we +[`UnliftIO.Temporary`](https://www.stackage.org/haddock/lts-10.2/unliftio-0.2.2.0/UnliftIO-Temporary.html), we can do some nice things: ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed -import System.IO.Temp (withSystemTempFile) +import UnliftIO.Temporary (withSystemTempFile) main :: IO () main = withSystemTempFile "date" $ \fp h -> do @@ -332,11 +335,11 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO (hClose) -import System.IO.Temp (withSystemTempFile) +import UnliftIO.Temporary (withSystemTempFile) import Control.Monad (replicateM_) main :: IO () @@ -362,7 +365,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -374,7 +377,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed @@ -387,11 +390,11 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process --package temporary +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO -import System.IO.Temp (withSystemTempFile) +import UnliftIO.Temporary (withSystemTempFile) main :: IO () main = withSystemTempFile "input" $ \fp h -> do @@ -413,7 +416,7 @@ ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed import System.IO @@ -440,13 +443,14 @@ ## Other settings We've so far only played with modifying streams, but there are a -number of other settings you can tweak. It's best to just look at the -API docs for all available functions. We'll give examples of the two -most common settings: the working directory and environment variables. +number of other settings you can tweak. It's best to just +[look at the API docs](https://www.stackage.org/package/typed-process) +for all available functions. We'll give examples of the two most +common settings: the working directory and environment variables. ```haskell #!/usr/bin/env stack --- stack --resolver lts-7.3 --install-ghc runghc --package typed-process +-- stack --resolver lts-10.2 script {-# LANGUAGE OverloadedStrings #-} import System.Process.Typed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typed-process-0.1.0.0/src/System/Process/Typed.hs new/typed-process-0.2.2.0/src/System/Process/Typed.hs --- old/typed-process-0.1.0.0/src/System/Process/Typed.hs 2016-10-21 07:46:42.000000000 +0200 +++ new/typed-process-0.2.2.0/src/System/Process/Typed.hs 2018-03-19 13:40:44.000000000 +0100 @@ -6,7 +6,15 @@ {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE ScopedTypeVariables #-} --- | Please see the README.md file for examples of using this API. +{-| +Please see the README.md file for examples of using this API. + +__Applications using this library MUST use @-threaded@__ to link with the +threaded version of the RTS. 'spawnProcess' and the others spawn a Haskell +thread that blocks until the process exits. Without @-threaded@ this will block +/all/ the Haskell threads in your program until the spawned process exits. + +-} module System.Process.Typed ( -- * Types ProcessConfig @@ -24,7 +32,9 @@ , setStdout , setStderr , setWorkingDir + , setWorkingDirInherit , setEnv + , setEnvInherit , setCloseFds , setCreateGroup , setDelegateCtlc @@ -35,7 +45,9 @@ #endif #if MIN_VERSION_process(1, 4, 0) && !WINDOWS , setChildGroup + , setChildGroupInherit , setChildUser + , setChildUserInherit #endif -- * Stream specs @@ -48,10 +60,6 @@ , useHandleOpen , useHandleClose - -- ** Conduit - , createSink - , createSource - -- * Launch a process , startProcess , stopProcess @@ -61,6 +69,10 @@ , readProcess_ , runProcess , runProcess_ + , readProcessStdout + , readProcessStdout_ + , readProcessStderr + , readProcessStderr_ -- * Interact with a process @@ -80,15 +92,16 @@ -- * Exceptions , ExitCodeException (..) , ByteStringOutputException (..) + -- * Unsafe functions + , unsafeProcessHandle ) where import qualified Data.ByteString as S import Data.ByteString.Lazy.Internal (defaultChunkSize) -import Control.Exception (throwIO) +import Control.Exception (assert, evaluate, throwIO, Exception, SomeException, finally, bracket, onException, catch) import Control.Monad (void) import Control.Monad.IO.Class import qualified System.Process as P -import Control.Monad.Catch as C import Data.Typeable (Typeable) import System.IO (Handle, hClose) import Control.Concurrent.Async (async, cancel, waitCatch) @@ -97,9 +110,6 @@ import qualified Data.ByteString.Lazy as L import qualified Data.ByteString.Lazy.Char8 as L8 import Data.String (IsString (fromString)) -import Data.Conduit (ConduitM) -import qualified Data.Conduit as C -import qualified Data.Conduit.Binary as CB #if MIN_VERSION_process(1, 4, 0) && !WINDOWS import System.Posix.Types (GroupID, UserID) @@ -330,6 +340,14 @@ -> ProcessConfig stdin stdout stderr setWorkingDir dir pc = pc { pcWorkingDir = Just dir } +-- | Inherit the working directory from the parent process. +-- +-- @since 0.2.2.0 +setWorkingDirInherit + :: ProcessConfig stdin stdout stderr + -> ProcessConfig stdin stdout stderr +setWorkingDirInherit pc = pc { pcWorkingDir = Nothing } + -- | Set the environment variables of the child process. -- -- Default: current process's environment. @@ -340,6 +358,14 @@ -> ProcessConfig stdin stdout stderr setEnv env pc = pc { pcEnv = Just env } +-- | Inherit the environment variables from the parent process. +-- +-- @since 0.2.2.0 +setEnvInherit + :: ProcessConfig stdin stdout stderr + -> ProcessConfig stdin stdout stderr +setEnvInherit pc = pc { pcEnv = Nothing } + -- | Should we close all file descriptors besides stdin, stdout, and -- stderr? See 'P.close_fds' for more information. -- @@ -425,6 +451,14 @@ -> ProcessConfig stdin stdout stderr setChildGroup x pc = pc { pcChildGroup = Just x } +-- | Inherit the group from the parent process. +-- +-- @since 0.2.2.0 +setChildGroupInherit + :: ProcessConfig stdin stdout stderr + -> ProcessConfig stdin stdout stderr +setChildGroupInherit pc = pc { pcChildGroup = Nothing } + -- | Set the child process's user ID with the POSIX @setuid@ syscall, -- does nothing on non-POSIX. See 'P.child_user'. -- @@ -436,6 +470,14 @@ -> ProcessConfig stdin stdout stderr -> ProcessConfig stdin stdout stderr setChildUser x pc = pc { pcChildUser = Just x } + +-- | Inherit the user from the parent process. +-- +-- @since 0.2.2.0 +setChildUserInherit + :: ProcessConfig stdin stdout stderr + -> ProcessConfig stdin stdout stderr +setChildUserInherit pc = pc { pcChildUser = Nothing } #endif -- | Create a new 'StreamSpec' from the given 'P.StdStream' and a @@ -536,22 +578,6 @@ useHandleClose :: Handle -> StreamSpec anyStreamType () useHandleClose h = mkStreamSpec (P.UseHandle h) $ \_ Nothing -> return ((), hClose h) --- | Provide input to a process by writing to a conduit. --- --- @since 0.1.0.0 -createSink :: MonadIO m => StreamSpec 'STInput (ConduitM S.ByteString o m ()) -createSink = - (\h -> C.addCleanup (\_ -> liftIO $ hClose h) (CB.sinkHandle h)) - <$> createPipe - --- | Read output from a process by read from a conduit. --- --- @since 0.1.0.0 -createSource :: MonadIO m => StreamSpec 'STOutput (ConduitM i S.ByteString m ()) -createSource = - (\h -> C.addCleanup (\_ -> liftIO $ hClose h) (CB.sourceHandle h)) - <$> createPipe - -- | Launch a process based on the given 'ProcessConfig'. You should -- ensure that you close 'stopProcess' on the result. It's usually -- better to use one of the functions in this module which ensures @@ -620,7 +646,9 @@ -- then call waitForProcess ourselves Left _ -> do P.terminateProcess pHandle - void $ P.waitForProcess pHandle + ec <- P.waitForProcess pHandle + success <- atomically $ tryPutTMVar pExitCode ec + evaluate $ assert success () return Process {..} where @@ -638,24 +666,28 @@ -> m () stopProcess = liftIO . pCleanup --- | Use the bracket pattern to call 'startProcess' and ensure +-- | Uses the bracket pattern to call 'startProcess' and ensures that -- 'stopProcess' is called. -- +-- In version 0.2.0.0, this function was monomorphized to @IO@ to +-- avoid a dependency on the exceptions package. +-- -- @since 0.1.0.0 -withProcess :: (MonadIO m, C.MonadMask m) - => ProcessConfig stdin stdout stderr - -> (Process stdin stdout stderr -> m a) - -> m a -withProcess config = C.bracket (startProcess config) stopProcess +withProcess :: ProcessConfig stdin stdout stderr + -> (Process stdin stdout stderr -> IO a) + -> IO a +withProcess config = bracket (startProcess config) stopProcess -- | Same as 'withProcess', but also calls 'checkExitCode' -- +-- In version 0.2.0.0, this function was monomorphized to @IO@ to +-- avoid a dependency on the exceptions package. +-- -- @since 0.1.0.0 -withProcess_ :: (MonadIO m, C.MonadMask m) - => ProcessConfig stdin stdout stderr - -> (Process stdin stdout stderr -> m a) - -> m a -withProcess_ config = C.bracket +withProcess_ :: ProcessConfig stdin stdout stderr + -> (Process stdin stdout stderr -> IO a) + -> IO a +withProcess_ config = bracket (startProcess config) (\p -> stopProcess p `finally` checkExitCode p) @@ -699,6 +731,70 @@ pc' = setStdout byteStringOutput $ setStderr byteStringOutput pc +-- | Same as 'readProcess', but only read the stdout of the process. Original settings for stderr remain. +-- +-- @since 0.2.1.0 +readProcessStdout + :: MonadIO m + => ProcessConfig stdin stdoutIgnored stderr + -> m (ExitCode, L.ByteString) +readProcessStdout pc = + liftIO $ withProcess pc' $ \p -> atomically $ (,) + <$> waitExitCodeSTM p + <*> getStdout p + where + pc' = setStdout byteStringOutput pc + +-- | Same as 'readProcessStdout', but instead of returning the +-- 'ExitCode', checks it with 'checkExitCode'. +-- +-- @since 0.2.1.0 +readProcessStdout_ + :: MonadIO m + => ProcessConfig stdin stdoutIgnored stderr + -> m L.ByteString +readProcessStdout_ pc = + liftIO $ withProcess pc' $ \p -> atomically $ do + stdout <- getStdout p + checkExitCodeSTM p `catchSTM` \ece -> throwSTM ece + { eceStdout = stdout + } + return stdout + where + pc' = setStdout byteStringOutput pc + +-- | Same as 'readProcess', but only read the stderr of the process. Original settings for stderr remain. +-- +-- @since 0.2.1.0 +readProcessStderr + :: MonadIO m + => ProcessConfig stdin stderrIgnored stderr + -> m (ExitCode, L.ByteString) +readProcessStderr pc = + liftIO $ withProcess pc' $ \p -> atomically $ (,) + <$> waitExitCodeSTM p + <*> getStderr p + where + pc' = setStderr byteStringOutput pc + +-- | Same as 'readProcessStderr', but instead of returning the +-- 'ExitCode', checks it with 'checkExitCode'. +-- +-- @since 0.2.1.0 +readProcessStderr_ + :: MonadIO m + => ProcessConfig stdin stderrIgnored stderr + -> m L.ByteString +readProcessStderr_ pc = + liftIO $ withProcess pc' $ \p -> atomically $ do + stderr <- getStderr p + checkExitCodeSTM p `catchSTM` \ece -> throwSTM ece + { eceStderr = stderr + } + return stderr + where + pc' = setStderr byteStringOutput pc + -- | Run the given process, wait for it to exit, and returns its -- 'ExitCode'. -- @@ -708,7 +804,8 @@ -> m ExitCode runProcess pc = liftIO $ withProcess pc waitExitCode --- | Same as 'runProcess', but ignores the 'ExitCode'. +-- | Same as 'runProcess', but instead of returning the +-- 'ExitCode', checks it with 'checkExitCode'. -- -- @since 0.1.0.0 runProcess_ :: MonadIO m @@ -806,7 +903,9 @@ [ "Received " , show (eceExitCode ece) , " when running\n" - , show (eceProcessConfig ece) + -- Too much output for an exception if we show the modified + -- environment, so hide it + , show (eceProcessConfig ece) { pcEnv = Nothing } , if L.null (eceStdout ece) then "" else "Standard output:\n\n" ++ L8.unpack (eceStdout ece) @@ -822,3 +921,25 @@ data ByteStringOutputException = ByteStringOutputException SomeException (ProcessConfig () () ()) deriving (Show, Typeable) instance Exception ByteStringOutputException + +-- | Take 'System.Process.ProcessHandle' out of the 'Process'. +-- This method is needed in cases one need to use low level functions +-- from the @process@ package. Use cases for this method are: +-- +-- 1. Send a special signal to the process. +-- 2. Terminate the process group instead of terminating single process. +-- 3. Use platform specific API on the underlying process. +-- +-- This method is considered unsafe because the actions it performs on +-- the underlying process may overlap with the functionality that +-- @typed-process@ provides. For example the user should not call +-- 'System.Process.waitForProcess' on the process handle as eiter +-- 'System.Process.waitForProcess' or 'stopProcess' will lock. +-- Additionally, even if process was terminated by the +-- 'System.Process.terminateProcess' or by sending signal, +-- 'stopProcess' should be called either way in order to cleanup resources +-- allocated by the @typed-process@. +-- +-- @since 0.1.1 +unsafeProcessHandle :: Process stdin stdout stderr -> P.ProcessHandle +unsafeProcessHandle = pHandle diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typed-process-0.1.0.0/test/System/Process/TypedSpec.hs new/typed-process-0.2.2.0/test/System/Process/TypedSpec.hs --- old/typed-process-0.1.0.0/test/System/Process/TypedSpec.hs 2016-10-21 07:46:42.000000000 +0200 +++ new/typed-process-0.2.2.0/test/System/Process/TypedSpec.hs 2018-03-19 13:34:42.000000000 +0100 @@ -4,17 +4,15 @@ import System.Process.Typed import System.IO -import Data.Conduit -import qualified Data.Conduit.Binary as CB -import Network.HTTP.Simple import Control.Concurrent.Async (Concurrently (..)) +import Control.Concurrent.STM (atomically) import Test.Hspec import System.Exit import System.IO.Temp import qualified Data.ByteString as S +import qualified Data.ByteString.Lazy as L import Data.String (IsString) import Data.Monoid ((<>)) -import qualified Data.Conduit.List as CL import qualified Data.ByteString.Base64 as B64 #if !MIN_VERSION_base(4, 8, 0) @@ -76,16 +74,15 @@ runProcess_ "false" `shouldThrow` \ExitCodeException{} -> True it "async" $ withSystemTempFile "httpbin" $ \fp h -> do - bss <- withProcess (setStdin createSink $ setStdout createSource "base64") $ \p -> + lbs <- withProcess (setStdin createPipe $ setStdout byteStringOutput "base64") $ \p -> runConcurrently $ - Concurrently - ( httpSink "https://raw.githubusercontent.com/fpco/typed-process/master/README.md" $ \_res -> - CB.conduitHandle h .| getStdin p) *> - Concurrently - ( runConduit - $ getStdout p - .| CL.consume) + Concurrently (do + bs <- S.readFile "README.md" + S.hPut h bs + S.hPut (getStdin p) bs + hClose (getStdin p)) *> + Concurrently (atomically $ getStdout p) hClose h - let encoded = S.filter (/= 10) $ S.concat bss + let encoded = S.filter (/= 10) $ L.toStrict lbs raw <- S.readFile fp encoded `shouldBe` B64.encode raw diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typed-process-0.1.0.0/typed-process.cabal new/typed-process-0.2.2.0/typed-process.cabal --- old/typed-process-0.1.0.0/typed-process.cabal 2016-10-21 07:46:42.000000000 +0200 +++ new/typed-process-0.2.2.0/typed-process.cabal 2018-03-19 13:39:31.000000000 +0100 @@ -1,51 +1,67 @@ -name: typed-process -version: 0.1.0.0 -synopsis: Run external processes, with strong typing of streams -description: Please see README.md -homepage: https://github.com/fpco/typed-process#readme -license: MIT -license-file: LICENSE -author: Michael Snoyman -maintainer: mich...@snoyman.com -category: System -build-type: Simple -extra-source-files: README.md ChangeLog.md -cabal-version: >=1.10 +-- This file has been generated from package.yaml by hpack version 0.21.2. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 11068332a1f3de188a488a22fdb0b1bc49f70ccc1dd04c322123278d6d6124e3 -library - hs-source-dirs: src - exposed-modules: System.Process.Typed - build-depends: base >= 4.7 && < 5 - , async - , bytestring - , conduit - , conduit-extra - , exceptions - , process >= 1.2 - , stm - , transformers - if os(windows) - cpp-options: -DWINDOWS - default-language: Haskell2010 +name: typed-process +version: 0.2.2.0 +synopsis: Run external processes, with strong typing of streams +description: Please see the tutorial at <https://haskell-lang.org/library/typed-process> +category: System +homepage: https://haskell-lang.org/library/typed-process +bug-reports: https://github.com/fpco/typed-process/issues +author: Michael Snoyman +maintainer: mich...@snoyman.com +license: MIT +license-file: LICENSE +build-type: Simple +cabal-version: >= 1.10 -test-suite typed-process-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - other-modules: System.Process.TypedSpec - build-depends: base - , async - , base64-bytestring - , bytestring - , conduit - , conduit-extra - , hspec - , http-conduit >= 2.1.10 - , temporary - , typed-process - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 +extra-source-files: + ChangeLog.md + README.md source-repository head - type: git + type: git location: https://github.com/fpco/typed-process + +library + exposed-modules: + System.Process.Typed + other-modules: + Paths_typed_process + hs-source-dirs: + src + build-depends: + async + , base >=4.7 && <5 + , bytestring + , process >=1.2 + , stm + , transformers + if os(windows) + cpp-options: -DWINDOWS + default-language: Haskell2010 + +test-suite typed-process-test + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + System.Process.TypedSpec + Paths_typed_process + hs-source-dirs: + test + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + async + , base >=4.7 && <5 + , base64-bytestring + , bytestring + , hspec + , process >=1.2 + , stm + , temporary + , transformers + , typed-process + default-language: Haskell2010