Mon, 05 May 2003 11:10:51 +0100
Is there a bug in the GHC implementation of the popen function that
manifests itself when more than 4k is written to the pipe?
I'm trying to reproduce in Haskell the standard UNIX shell pipe idiom:
cat 4097 | cat
where 4097 is a file containing 4097 bytes. My Haskell code looks as
-- snip --
main :: IO ()
main = do sequence_ $ map printChunk chunks
printChunk :: String -> IO ()
= do (find_output, _, _) <- popen "cat"  (Just str)
(cat_output, _, _) <- popen "cat"  (Just find_output)
putStrLn $ show (length str)
lengths = [4095,4096..]
str = repeat 'a'
chunks = zipWith take lengths (repeat str)
-- end snip --
I get two pieces of output, one for each of the 4095 and 4096 bytes, but
nothing for 4097 bytes, the program just hangs.
Is this some bizarre feature of lazy evaluation, or a mistake in the way
that popen is implemented (or both)?
I'm using ghc-5.04.3 on linux 2.4.20-8 (Red Hat 9).
On the move? Get Hotmail on your mobile phone http://www.msn.co.uk/mobile