tail does not exit

Erik Osterholm freebsd-lists-erik at erikosterholm.org
Thu Dec 20 08:12:58 PST 2007

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
aleph:~$ tail -f test | awk '{print $1; exit 0}'

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.


More information about the freebsd-questions mailing list