From owner-freebsd-questions@FreeBSD.ORG Thu Dec 20 16:12:58 2007 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6791C16A41A for ; Thu, 20 Dec 2007 16:12:58 +0000 (UTC) (envelope-from erik@cepheid.org) Received: from mail.cepheid.org (aleph.cepheid.org [72.232.60.94]) by mx1.freebsd.org (Postfix) with ESMTP id 3C9CF13C4F5 for ; Thu, 20 Dec 2007 16:12:58 +0000 (UTC) (envelope-from erik@cepheid.org) Received: by mail.cepheid.org (Postfix, from userid 1006) id 45DCA9B4058; Thu, 20 Dec 2007 09:53:36 -0600 (CST) Date: Thu, 20 Dec 2007 09:53:36 -0600 From: Erik Osterholm To: Mikhail Teterin Message-ID: <20071220155336.GA31047@aleph.cepheid.org> References: <200712192322.lBJNMfps053071@aldan.algebra.com> <200712200516.30702@aldan> <86ejdh4psf.fsf@bsd.by> <200712200540.11553@aldan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200712200540.11553@aldan> User-Agent: Mutt/1.4.2.3i Cc: questions@freebsd.org, "Max N. Boyarov" Subject: Re: tail does not exit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2007 16:12:58 -0000 On Thu, Dec 20, 2007 at 05:40:11AM -0500, Mikhail Teterin wrote: > On ?????? 20 ??????? 2007, Max N. Boyarov wrote: = | MT> Is not that > a bug in itself? = = | Tail write buffer at all, i.e. all 10 lines > writes to pipe. > > So, the behavior depends on the size of the buffer -- and thus the > size of the input lines. > > A bug indeed... I don't understand. aleph:~$ cat test blah1 blah2 blah3 aleph:~$ tail -f test | awk '{print $1; exit 0}' blah1 (hangs) This is expected. Awk printed one time and exited, per the given script. The output from tail/input from awk went all at once, awk printed the first line, exited, and the rest of the input disappeared. 'tail' sent "blah1\nblah2\nblah3\n" to awk, awk printed until the first newline and exited. If I now write to test from another terminal: aleph:~$ echo "blah4" >> test Tail tries to write to the pipe, which it finds closed. It receives a SIGPIPE (tried to write to a pope with no reader--see man signal), and it terminates. The same behavior happens if I use a larger file. I see no inconsistent behavior, nor any bugs. Erik