From owner-freebsd-hackers Sat Dec 2 9:30:30 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from homer.softweyr.com (bsdconspiracy.net [208.187.122.220]) by hub.freebsd.org (Postfix) with ESMTP id 8056237B400 for ; Sat, 2 Dec 2000 09:30:28 -0800 (PST) Received: from [127.0.0.1] (helo=softweyr.com ident=Fools trust ident!) by homer.softweyr.com with esmtp (Exim 3.16 #1) id 142GDY-000072-00; Sat, 02 Dec 2000 10:12:56 -0700 Message-ID: <3A292D98.E655D755@softweyr.com> Date: Sat, 02 Dec 2000 10:12:56 -0700 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: Charlie & Cc: hackers@FreeBSD.org Subject: Re: pipe References: <20001202085127.A301@int80h.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Charlie & wrote: > > Sorry if this is a dumb question, but after years of DOS programming, I > am still discovering the subletiest of Unix: > > When I create a pipe, do I have to use it for interprocess communication > only, or can the same process write to one end and later read from the > other? > > What I am looking for is to use it as a FIFO-style buffer. Instead of > allocating and reallocating memory, let the system worry about how > much memory the data needs. This is for a two (or more) pass compiler, > which reads from stdin and writes to stdout. It does not know how much > data it still has coming in, so it has no idea how much memory it needs > to store information in, yet after one pass it needs to read it in the > same order it was written (FIFO). > > If this is possible, is there a limit as to how much I can write to the > pipe before I start reading it, or is it limitless (within reason, of > course)? Yes, you can read from your own pipe, and yes the buffering availabe in the pipe is limited. IIRC, the pipe size is 8K. -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message