tail does not exit

Mikhail Teterin mi+kde at aldan.algebra.com
Thu Dec 20 02:11:34 PST 2007


On середа 19 грудень 2007, Chuck Swiger wrote:
= A quick test suggests that "tail -f" will close when it gets a SIGPIPE.

SIGPIPE? How is that relevant? Does tail get a SIGPIPE, when awk disappears
in my example? If it does not, why do you bring it up?

And if it does get SIGPIPE, then you are wrong, because the posted
"quick test" shows the exact opposite behavior -- tail does NOT go
away.

Please, clarify... Thanks.

On середа 19 грудень 2007, Max N. Boyarov wrote:
=  try to test your script with anoter file and add somthing to it
= 
= 1) cons1$ touch /tmp/test
= 2)  cons1$ tail -f /tmp/test | awk '{print "Line: " $1 ;  exit(0)}END{print "Bye"}'
= 2a)  Line: Line1
= 2b)  Bye

I'm sorry, this does not make sense to me. Starting with an empty
file, as you do in 1), /may/ make tail not notice, that awk went
away, because tail has nothing to write to stdout.

But /var/log/messages is not empty, and awk -- in my example -- would
exit upon seeing the very first line of its input (tail's output).
Yet tail fails to notice, that its subsequent output (starting with the
second line) is written to nowhere...

Why?

	-mi

P.S. Here is the example again:

#!/bin/sh

if tail -f /var/log/messages | awk '{print "Exiting"; exit 0}'
then
        echo Exited
else
        echo Failed
fi

exit 0


More information about the freebsd-questions mailing list