reading and writing to another process

alanw at microsoft.UUCP alanw at microsoft.UUCP
Tue Oct 4 12:07:36 AEST 1983


Dave Sherman's solution to the problem of writing to and reading
from a process must be taken with a grain of salt.  Unless one
has some knowledge about the behavior of the program through which
the data is being filtered, it is very easy to block on either the
input or the output.  For example, if the filter is something like
sort which reads all of its input before writing anything, the pro-
gram must write all its output to the pipe and close the write des-
criptor before attempting to read the input.

If, on the other hand, the filter is a more ordinary one like grep,
it is very difficult to tell when to read from or write to the pipe.
If the total amount to be written is less than one pipe buffer full
(normally 4096 characters), it's okay to to write the full output,
close the write descriptor and then read the filter's output.  In
other cases there is no way to tell if input is available from the
pipe or if there is space in the pipe for the output of the write.

			Alan Whitney
			Microsoft Corp.
			{decvax,uw-beaver,fluke}!microsoft!alanw



More information about the Comp.unix mailing list