From owner-freebsd-questions@FreeBSD.ORG Thu Dec 20 10:11:34 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 0716516A418 for ; Thu, 20 Dec 2007 10:11:34 +0000 (UTC) (envelope-from mi+kde@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.freebsd.org (Postfix) with ESMTP id ABC8813C46A for ; Thu, 20 Dec 2007 10:11:33 +0000 (UTC) (envelope-from mi+kde@aldan.algebra.com) Received: from aldan.algebra.com (localhost [127.0.0.1]) by aldan.algebra.com (8.14.1/8.14.1) with ESMTP id lBK9wSZA054792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 20 Dec 2007 04:58:28 -0500 (EST) (envelope-from mi+kde@aldan.algebra.com) Received: from localhost (localhost [[UNIX: localhost]]) by aldan.algebra.com (8.14.1/8.14.1/Submit) id lBK9wSUw054791; Thu, 20 Dec 2007 04:58:28 -0500 (EST) (envelope-from mi+kde@aldan.algebra.com) From: Mikhail Teterin To: "Max N. Boyarov" , Chuck Swiger Date: Thu, 20 Dec 2007 04:58:27 -0500 User-Agent: KMail/1.9.7 References: <200712192322.lBJNMfps053071@aldan.algebra.com> <200712191906.16254.mi+mill@aldan.algebra.com> <86r6hixiyn.fsf@bsd.by> In-Reply-To: <86r6hixiyn.fsf@bsd.by> X-Face: %UW#n0|w>ydeGt/b@1-.UFP=K^~-:0f#O:D7whJ5G_<5143Bb3kOIs9XpX+"V+~$adGP:J|SLieM31VIhqXeLBli" 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 10:11:34 -0000 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