Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site microsoft.UUCP Path: utzoo!linus!decvax!harpo!eagle!mhuxi!houxm!hogpc!houti!ariel!vax135!cornell!uw-beaver!microsoft!alanw From: alanw@microsoft.UUCP Newsgroups: net.unix Subject: Re: reading and writing to another process Message-ID: <8658@microsoft.UUCP> Date: Mon, 3-Oct-83 22:07:36 EDT Article-I.D.: microsof.8658 Posted: Mon Oct 3 22:07:36 1983 Date-Received: Thu, 6-Oct-83 23:26:47 EDT References: <429@nsc.uucp>, <2399@utcsrgv.UUCP> Organization: Microsoft Corporation Lines: 20 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