Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Dec 2007 12:35:28 +0200
From:      m.boyarov@bsd.by (Max N. Boyarov)
To:        Mikhail Teterin <mi+kde@aldan.algebra.com>
Cc:        questions@freebsd.org
Subject:   Re: tail does not exit
Message-ID:  <86ejdh4psf.fsf@bsd.by>
In-Reply-To: <200712200516.30702@aldan> (Mikhail Teterin's message of "Thu, 20 Dec 2007 05:16:30 -0500")
References:  <200712192322.lBJNMfps053071@aldan.algebra.com> <200712200458.27988@aldan> <86wsr98ylt.fsf@bsd.by> <200712200516.30702@aldan>

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>  On =D1=87=D0=B5=D1=82=D0=B2=D0=B5=D1=80 20 =D0=B3=D1=80=D1=83=D0=B4=
=D0=B5=D0=BD=D1=8C 2007, Max N. Boyarov wrote:
 MT> =3D after something writeln to /var/log/messages tail get SIGPIPE

 MT> But why is that needed for tail to notice? It is trying to output 10 l=
ines.

 MT> After it outputs the very first one of them, awk exits, and the 9 subs=
equent=20
 MT> lines go into thin air /without tail noticing/.
=20
 MT> Is not that a bug in itself?

 Tail write buffer at all, i.e. all 10 lines writes to pipe.

$ cat test=20=20=20
line1
line2
line3
line4
line5
line6
line7
line8
line9
line10
line11

 tail -f test | awk '{print "Exiting" $1;  exit 0}'

 open("test", O_RDONLY)                  =3D 3
fstat(3, {st_mode=3DS_IFREG|0644, st_size=3D68, ...}) =3D 0
syscall_477(0, 0x44, 0x1, 0x1, 0x3, 0, 0) =3D 0x28175000
write(1, "line2\nline3\nline4\nline5\nline6\nli"..., 62Exitingline2
) =3D 62
fstat(3, {st_mode=3DS_ISUID|S_ISVTX|070, st_size=3D0, ...}) =3D 0
syscall_478(0x3, 0, 0, 0x1)             =3D 0
syscall_478(0x3, 0, 0, 0)               =3D 0
read(3, "line1\nline2\nline3\nline4\nline5\nli"..., 4096) =3D 68
^^^^^^^^^^^^^^^^^^^^^^ write buff ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

munmap(0x28175000, 68)                  =3D 0
read(3, "", 4096)                       =3D 0
kqueue(0x28172d40)                      =3D 4
syscall_397(0x3, 0xbfbfe44c)            =3D 0
kevent(0x4, 0x28205040, 0x1, 0, 0, 0xbfbfe624) =3D 0
kevent(0x4, 0, 0, 0x28205040, 0x1, 0)   =3D 1
read(3, "line++\n", 4096)               =3D 7
^^^^^^^^^^^^^^^^^^^^^^ new line added ^^^^^^^^^^^^^^^^^^^^^

fstat(1, {st_mode=3D031545, st_size=3D7596457873570623081, ...}) =3D 0
read(3, "", 4096)                       =3D 0
write(1, "line++\n", 7)                 =3D -1 EPIPE (Broken pipe)
^^^^^^^^^ try write ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

=2D-- SIGPIPE (Broken pipe: 13) ---
=2D-- SIGPIPE (Broken pipe: 13) ---
^^^^^^^^ exit ^^^^^^^^^^^^^

=2D-=20
Max N. Boyarov

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

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

iD8DBQFHakV0XJXgXMoFno8RAnUaAJ4g0r0TY2Td+Em+4CAboeUrnLPMpACgqt8I
Yn6f9ptNcb4YQjv+A8L/sCw=
=huQF
-----END PGP SIGNATURE-----
--=-=-=--



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