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 =D3=C5=D2=C5=C4=C1 19 =C7=D2=D5=C4=C5=CE=D8 2007, Chuck Swiger wrote: =3D 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 =D3=C5=D2=C5=C4=C1 19 =C7=D2=D5=C4=C5=CE=D8 2007, Max N. Boyarov wrote: =3D =9Atry to test your script with anoter file and add somthing to it =3D=20 =3D 1) cons1$ touch /tmp/test =3D 2) =9Acons1$ tail -f /tmp/test | awk '{print "Line: " $1 ; =9Aexit(0)}E= ND{print "Bye"}' =3D 2a) =9ALine: Line1 =3D 2b) =9ABye 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>