Date: Thu, 20 Dec 2007 04:58:27 -0500 From: Mikhail Teterin <mi+kde@aldan.algebra.com> To: "Max N. Boyarov" <m.boyarov@bsd.by>, Chuck Swiger <cswiger@mac.com> Cc: questions@freebsd.org Subject: Re: tail does not exit Message-ID: <200712200458.27988@aldan> In-Reply-To: <86r6hixiyn.fsf@bsd.by> References: <200712192322.lBJNMfps053071@aldan.algebra.com> <200712191906.16254.mi%2Bmill@aldan.algebra.com> <86r6hixiyn.fsf@bsd.by>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712200458.27988>
