From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <57E90700-85A0-47F4-9156-DE732859A74C@gmail.com> References: <57E90700-85A0-47F4-9156-DE732859A74C@gmail.com> From: Charles Forsyth Date: Sun, 2 Apr 2017 18:20:05 +0100 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1143c0a0fd36f7054c3240c5 Subject: Re: [9fans] pipe: bug or feature? Topicbox-Message-UUID: b91e9fba-ead9-11e9-9d60-3106f5b1d025 --001a1143c0a0fd36f7054c3240c5 Content-Type: text/plain; charset=UTF-8 On 28 March 2017 at 01:05, arisawa wrote: > the program reads a file and writes it to one end of pipe and then reads > it from another end of pipe. > the buffer for writing pipe is named buf0, and for reading pipe is named > buf. > The general problem with this is that a pipe is a full-duplex communication channel, not a storage device. The implementation has buffering, but it's not guaranteed to hold a file of any particular size. Obviously in practice you're fine if the file is "small enough", but how small is that? Having the same process write and read the pipe won't work in general. The buffer will fill up and the writer will block, which is just right ... if it's not also the reader. --001a1143c0a0fd36f7054c3240c5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 28 March 2017 at 01:05, arisawa <karisawa@gmail.com> wro= te:
the program reads a file and writes it to one end of pipe= and then reads it from another end of pipe.
the buffer for writing pipe is named buf0, and for reading pipe is named bu= f.

The general problem with this is that a pipe= is a full-duplex communication channel, not a storage device.
The implementation has buffering, but it's not guar= anteed to hold a file of any particular size.
Obviously in practice you're fine if the file is "small enough&= quot;, but how small is that?
Having the sa= me process write and read the pipe won't work in general.
The buffer will fill up and the writer will block, which= is just right ... if it's not also the reader.

--001a1143c0a0fd36f7054c3240c5--