
I meant do you have an example of your working code.
Sure.
localhost% cat Main.hs
module Main where
import SubProcess
main = do cs <- subprocess "/bin/cat" [] (Just $ replicate 10000 $ 'a') putStrLn $ show $ length cs
localhost% ghc -package posix --make -o foo Main.hs ghc-5.03: chasing modules from: Main.hs Compiling SubProcess ( SubProcess.lhs, SubProcess.o ) Compiling Main ( Main.hs, ./Main.o ) ghc: linking ... localhost% ./foo 10000 localhost%
Note that is does leave zombie processes, since getProcessStatus is never called. I think, maybe appending something like the following to the ouput would work: output ++ (seq (unsafePerformIO childStatus) []) where childStatus = hClose roh ; getProcessStatus True False pid You would return childStatus along with the ouput. If the end of the string is reached, the zombie child will be reaped automatically. If you prematurely decide to stop reading the ouput, you have to call childStatus manually. I didn't bother to test it, because I didn't care about zombie processes. -- Sébastien