Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Dec 2007 03:17:52 +0200
From:      m.boyarov@bsd.by (Max N. Boyarov)
To:        Mikhail Teterin <mi+mill@aldan.algebra.com>
Cc:        questions@freebsd.org
Subject:   Re: tail does not exit
Message-ID:  <86r6hixiyn.fsf@bsd.by>
In-Reply-To: <200712191906.16254.mi%2Bmill@aldan.algebra.com> (Mikhail Teterin's message of "Wed, 19 Dec 2007 19:06:15 -0500")
References:  <200712192322.lBJNMfps053071@aldan.algebra.com> <86abo64543.fsf@bsd.by> <200712191906.16254.mi%2Bmill@aldan.algebra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable


>>>>> "MT" =3D=3D Mikhail Teterin writes:

 MT>  Max N. Boyarov:
 >> =C2=A0 =C2=A0 =C2=A0 -f =C2=A0 =C2=A0 =C2=A0The -f option causes tail t=
o not stop when end of file is
 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0reached, but rather to =
wait for additional data to be appended
 >> to the input. =C2=A0The -f option is ignored if the standard input is a=
 pipe,
 >> but not if it is a FIFO.

 MT> Josh Tolbert:
 >> Cause the -f option to tail doesn't work that way. -f always waits for =
more
 >> input.

 MT> I know very well about -f waiting for more *input*. What puzzles me, i=
s that=20
 MT> tail does not quit, when its *output* is closed.

 MT> James Harrison:
 >> Is there a reason you want the -f flag?

 MT> Yes, I want awk to be processing the lines, which are appended to the =
file,=20
 MT> until it finds, what it is looking for, and exits. I expect tail to go=
 away,=20
 MT> when its stdout is closed, but it does not.

 >> tail -f holds on for dear life until a ctrl-c happens. IT HAS A DEATH
 >> GRIP!

 MT> This seems like a bug to me... It should hold on to its input file(s),=
 but=20
 MT> exit peacefully, when its stdout closes. No?

 tail -f /tmp/foo | awk '{print "$1"}
=20
  tail write to pipe (reader wait data)   (2)=20
  reader get data (2a) and exit (2b). action (3) from another console
  tail write data to pipe again.   action (4) from another console
  tail get SIGPIPE
  tail exit

 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

3) cons2$  echo Line1 >> /tmp/test
4)  cons2$  echo Line2 >> /tmp/test
=20
=2D-=20
Max N. Boyarov

--=-=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)

iD8DBQFHacLEXJXgXMoFno8RAjCzAKDyzZ6YCjXwXJQ1quIMvWcI1NWX0ACfZoPp
VEwldRbW5DM4zbZxkQRxAIU=
=TD6c
-----END PGP SIGNATURE-----
--=-=-=--



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