[net.unix-wizards] possible pipe bug--the answer

whm.arizona%rand-relay@sri-unix.UUCP (06/10/83)

Thanks to all who responded to my article about the problem I was having
with using two pipes to a process.

As a brief review, I was opening read and write pipes to a
process and then trying to achieve terminal-like interaction with
the process.  In certain cases, lines that didn't terminate with
a newline never appeared.

There are two fundamental problems:
	
	(1) It is impossible to control what buffering the
	      child process does; it's on its own.

	(2) Some programs behave differently depending on what
	      they are reading from and writing to.  (Be it a
	      terminal, file, or pipe.)

Both these points are fairly obvious to me, but they didn't occur
to me at the appropriate time.  It was also mentioned that pipes
attach no special significance to \n, therefore, any problems must
be related to buffering rather than pipes.

Point 1 implies that if a program depends on stdio to flush an output
stream at an appropriate time, the program is likely to not act as
expected when talking to a pipe.

Point 2 implies that you can't use pipes to achieve terminal-like
interaction with programs like ex and ucbmail.  You can see how
a program x behaves in various i/o environments by trying the
following commands:
	x
	x | cat -u
	cat | x
	cat | x | cat -u
	
	
Thanks again to those who helped out.

					Bill Mitchell
					whm.arizona@rand-relay
					arizona!whm