From owner-freebsd-questions@FreeBSD.ORG Thu Dec 20 01:18:18 2007 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB6D116A417 for ; Thu, 20 Dec 2007 01:18:18 +0000 (UTC) (envelope-from m.boyarov@bsd.by) Received: from mx1.cybernet.by (mail.cybernet.by [212.98.164.131]) by mx1.freebsd.org (Postfix) with ESMTP id 7DF2613C4EE for ; Thu, 20 Dec 2007 01:18:18 +0000 (UTC) (envelope-from m.boyarov@bsd.by) Received: from mx1.cybernet.by (mx1.cybernet.by [127.0.0.10]) by mx1.cybernet.by (Postfix) with ESMTP id 324EBCDF5B5; Thu, 20 Dec 2007 03:14:00 +0200 (EET) Received: from solar.bsd.by (dragonsoul.aichyna.com [87.252.248.30]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.cybernet.by (Postfix) with ESMTP id 6BAD4CDF587; Thu, 20 Dec 2007 03:13:59 +0200 (EET) Received: by solar.bsd.by (Postfix, from userid 1001) id D292522860; Thu, 20 Dec 2007 03:17:56 +0200 (EET) X-Comment-To: Mikhail Teterin To: Mikhail Teterin References: <200712192322.lBJNMfps053071@aldan.algebra.com> <86abo64543.fsf@bsd.by> <200712191906.16254.mi+mill@aldan.algebra.com> From: m.boyarov@bsd.by (Max N. Boyarov) In-Reply-To: <200712191906.16254.mi+mill@aldan.algebra.com> (Mikhail Teterin's message of "Wed, 19 Dec 2007 19:06:15 -0500") X-Mailer: Gnus v5.11/GNU Emacs 22.1 Date: Thu, 20 Dec 2007 03:17:52 +0200 Message-ID: <86r6hixiyn.fsf@bsd.by> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Virus-Scanned: ClamAV Cc: questions@freebsd.org Subject: Re: tail does not exit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2007 01:18:18 -0000 --=-=-= 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----- --=-=-=--