Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Dec 2007 09:53:36 -0600
From:      Erik Osterholm <freebsd-lists-erik@erikosterholm.org>
To:        Mikhail Teterin <mi+kde@aldan.algebra.com>
Cc:        questions@freebsd.org, "Max N. Boyarov" <m.boyarov@bsd.by>
Subject:   Re: tail does not exit
Message-ID:  <20071220155336.GA31047@aleph.cepheid.org>
In-Reply-To: <200712200540.11553@aldan>
References:  <200712192322.lBJNMfps053071@aldan.algebra.com> <200712200516.30702@aldan> <86ejdh4psf.fsf@bsd.by> <200712200540.11553@aldan>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071220155336.GA31047>