Re: [Haskell-cafe] System.Posix, forked processes and psuedo terminals on Linux

2010-08-21 Thread Donn Cave
Quoth Erik de Castro Lopo mle...@mega-nerd.com,
...
 The code below *almost* works. Its currently printing out:

 parent : Forked child was here!
 parent : Message from parent.
 Read 21 bytes

 while I think it should print:

 parent : Forked child was here!
 parent : Read 21 bytes

 Any clues on why 'Message from parent.' is also ending up on
 stdout? This is ghc-6.12.1 on Debian Linux.

My guess is that the default tty attributes include ECHO.  So the
data you write to the master fd is echoed back, as though by the
fork process but actually by the terminal driver.  You can turn
ECHO off.

Donn Cave, d...@avvanta.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] System.Posix, forked processes and psuedo terminals on Linux

2010-08-21 Thread Erik de Castro Lopo
Donn Cave wrote:

 My guess is that the default tty attributes include ECHO.  So the
 data you write to the master fd is echoed back, as though by the
 fork process but actually by the terminal driver.  You can turn
 ECHO off.

Thanks very much Donn, that was an excellent guess.

Adding:

attr - getTerminalAttributes fd
setTerminalAttributes fd (withoutMode attr EnableEcho) Immediately

at the top of the runParent process gave me the results I expected.

Cheers,
Erik
-- 
--
Erik de Castro Lopo
http://www.mega-nerd.com/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe