[Haskell-cafe] catting to cat gets stuck at > 135K

Jason Dusek jason.dusek at gmail.com
Mon Nov 10 19:04:07 EST 2008


> > simple exe bytes args        =  do
> >   (i, o, e, p)            <-  runInteractiveProcess exe args Nothing
> > Nothing
> >   hPut i bytes
> >   s                       <-  hGetContents o
> >   hClose i
> >   return s
>
> Yep, that's your problem.  forkIO the hPut.

  Maybe I didn't do enough here -- just wrapping in `forkIO`
  does not seem to actually help.

--
_jsn




import Data.ByteString.Lazy
import System.Process
import System.Environment
import System.IO (hClose)
import Control.Concurrent
import Prelude hiding (writeFile, readFile)


main                         =  do
  exe:file:_                <-  getArgs
  bytes                     <-  readFile file
  foo                       <-  simple exe bytes []
  writeFile (file ++ ".foo") foo


 -- Manufactures a simple stream handler from a command line utility.
simple
 :: String -> ByteString -> [String] -> IO ByteString
simple exe bytes args        =  do
  (i, o, e, p)              <-  runInteractiveProcess exe args Nothing Nothing
  forkIO $ hPut i bytes
  s                         <-  hGetContents o
  return s


More information about the Haskell-Cafe mailing list