
Line buffered would be an inefficient default. Stdout is fully buffered in
c99 if it can be determined that it is not attached to a terminal.
Alexander
On Aug 2, 2014 5:07 AM, "Chris Myzie"
I'm reposting this message because I think it only went to the google group and not the official haskell-cafe list:
On Friday, August 1, 2014 10:06:32 AM UTC-4, Chris Myzie wrote:
As a workaround, I am able to trick the child haskell process into thinking it's running in an interactive terminal by wrapping it with /usr/bin/script:
createProcess (proc "/usr/bin/script" ["-qc","./A","/dev/null"]) { std_out = CreatePipe }
I still think haskell is using screwy defaults for stdout buffering..
On Thursday, July 31, 2014 3:24:47 PM UTC-4, Chris Myzie wrote:
Hello,
I'm trying to write a wrapper process that will be able to read any child process' stdout. The problem I'm running into is that unless I force the child's stdout to LineBuffering, it defaults to BlockBuffering. Is BlockBuffering really the default in this case? I don't want to have to modify all of the child processes that I want to use with this wrapper.
Below is a simple test case. A.hs is the child process, and B.hs is the wrapper. If I run B.hs, I will get no output unless I uncomment the line in A.hs.
Thanks, Chris
------------------------------ A.hs --------------------------- import Control.Concurrent import System.IO
main :: IO () main = do -- hSetBuffering stdout LineBuffering putStrLn "test" >> threadDelay 1000000 >> main
------------------------------ B.hs --------------------------- import Control.Monad import System.IO import System.Process
main :: IO () main = do (_,Just h,_,_) <- createProcess (proc "./A" []) { std_out = CreatePipe } hSetBuffering h LineBuffering forever $ hGetLine h >>= putStrLn
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe