From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 12 16:14:08 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 339FF1065678 for ; Fri, 12 Dec 2008 16:14:08 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from kabab.cs.huji.ac.il (kabab.cs.huji.ac.il [132.65.16.84]) by mx1.freebsd.org (Postfix) with ESMTP id E165B8FC22 for ; Fri, 12 Dec 2008 16:14:07 +0000 (UTC) (envelope-from danny@cs.huji.ac.il) Received: from pampa.cs.huji.ac.il ([132.65.80.32]) by kabab.cs.huji.ac.il with esmtp id 1LBAeU-00086X-I3; Fri, 12 Dec 2008 18:14:06 +0200 X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.2 To: rihad In-reply-to: <49426B64.1070004@mail.ru> References: <494235CA.2050101@mail.ru> <49426B64.1070004@mail.ru> Comments: In-reply-to rihad message dated "Fri, 12 Dec 2008 17:47:16 +0400." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 12 Dec 2008 18:14:06 +0200 From: Danny Braniss Message-ID: Cc: freebsd-hackers@freebsd.org Subject: Re: preventing FIFO from EOF X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2008 16:14:08 -0000 > Danny Braniss wrote: > >> $ mkfifo /var/tmp/foo > >> $ buffer -i /var/tmp/foo # misc/buffer > >> # in another console: > >> $ echo hi > /var/tmp/foo > >> > >> buffer prints hi and exits. I want it to keep reading and printing > >> indefinitely. > >> > >> Further experimentation revealed that I need two writers: one dummy > >> writer that just keeps /var/tmp/foo open for writing, and the other > >> doing the "real work". This way buffer wouldn't exit. But how to emulate > >> the dummy writer? It itself needs to block on something to keep > >> /var/tmp/foo open. Any clean way to do this in shell? Maybe the solution > >> is quite simple but isn't at the tip of my tongue. > >> > >> Thanks. > > > > too easy > > n csh: > > while 1 > > buffer -i /var/tmp/foo > > end > > or in sh: > > while true; do > > buffer -i /var/tmp/foo > > done > > > > > Thanks, but I should have said that buffer must always run to never miss any data. > > The reason being that buffer's output gets fed into another program that > shouldn't be restarted. use 'tail -f' instead of 'buffer -i' then, or place the while in file and execute that. BTW, buffer was written way back when memory was measured in kilobytes and the ethernet was 10 mgb, so things have changed a bit, and its effectivness is questionable :-) danny