| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
System.IO.Capture
- capture :: IO a -> IO (ByteString, ByteString, ByteString, Maybe ProcessStatus)
 - captureStream :: IO a -> IO (ByteString IO (), ByteString IO (), ByteString IO (), ProcessID)
 
Documentation
capture :: IO a -> IO (ByteString, ByteString, ByteString, Maybe ProcessStatus) Source
Capture an IO action's stdout, stderr, and any thrown exception. Waits
 for the action to complete before returning.
> (out, _, _, _) <-capture(putStrLn"foo") >capture(hPutStrLnstderr"bar") >captureundefined>
captureStream :: IO a -> IO (ByteString IO (), ByteString IO (), ByteString IO (), ProcessID) Source
Stream an IO action's stdout, stderr, and any thrown exception. Also
 returns the spawned process's pid to wait on (otherwise the process will
 become a zombie after terminating), kill, etc.
import qualified Data.ByteString.Streaming as S > let action =putStrLn"foo" >>threadDelay1000000 > (out, _, _, pid) <-captureStream(replicateM_5 action) > S.stdoutout foo foo foo foo foo >getProcessStatusTrue True pid Just (ExitedExitSuccess)