From unknown Fri Jun 13 11:24:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24495: tail -F does not terminate when running out of names to watch Resent-From: Julian =?UTF-8?Q?B=C3=BCning?= Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 21 Sep 2016 15:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 24495 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 24495@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.147447238110440 (code B ref -1); Wed, 21 Sep 2016 15:40:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Sep 2016 15:39:41 +0000 Received: from localhost ([127.0.0.1]:59724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmjcb-0002iJ-G0 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 11:39:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmiP0-0007ZV-89 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmiOu-00046T-72 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOu-00046L-3Q for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOr-0004A7-Sg for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmiOm-00045F-RC for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:25 -0400 Received: from mx-out-2.rwth-aachen.de ([134.130.5.187]:43569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOm-00044n-JQ for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:20 -0400 X-IronPort-AV: E=Sophos;i="5.30,373,1470693600"; d="scan'208";a="459219666" Received: from rwthex-s1-a.rwth-ad.de ([134.130.26.152]) by mx-2.rz.rwth-aachen.de with ESMTP; 21 Sep 2016 16:21:19 +0200 Received: from [134.61.86.206] (134.61.86.206) by rwthex-s1-a.rwth-ad.de (2002:8682:1a98::8682:1a98) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 21 Sep 2016 16:21:18 +0200 From: Julian =?UTF-8?Q?B=C3=BCning?= Date: Wed, 21 Sep 2016 16:22:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [134.61.86.206] X-ClientProxiedBy: rwthex-s2-b.rwth-ad.de (2002:8682:1a9b::8682:1a9b) To rwthex-s1-a.rwth-ad.de (2002:8682:1a98::8682:1a98) Message-ID: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Mailman-Approved-At: Wed, 21 Sep 2016 11:39:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) observed behavior: $ mkdir foo $ tail -F foo & [1] 1000 tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file; giving up on this name $ rmdir foo ; echo moo > foo $ jobs [1]+ Running tail -F foo & expected behavior option 1: $ mkdir foo $ tail -F foo & tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file; giving up on this name $ rmdir foo ; echo moo > foo [1]+ Done tail -F foo & expected behavior option 2: $ mkdir foo $ tail -F foo & [1] 1000 tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file $ rmdir foo ; echo moo > foo tail: 'foo' has appeared; following new file moo $ jobs [1]+ Running tail -F foo & tail does neither terminate nor display any contents of the file foo. We would assume that either tail terminates after displaying the error message (because there is no other file left) or that tail would infinitely retry to read a file with the same name and if such a file is created. We could reproduce this behavior with versions 8.25 on ArchLinux and 8.25 and 8.25.71-1db94 on Fedora (package and compiled from source) with and without ---disable-inotify. At least in version 8.25, tail_forever_inotify is not executed because any_non_remote_file returns false, which disables inotify in line 2361 (tail.c). We can trace the cause of this behavior for the non-inotify version of tail_forever: For a directory, the ignore flag in the corresponding struct File_spec is set to true. Thus, tail_forever skips this file in line 1130 (tail.c) and does not modify this flag during any iteration of the enclosing while(1). Since no check is being done if any valid target remains, this leads to the observed non-terminating behavior. This behavior was found using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. Regards, Julian Büning From unknown Fri Jun 13 11:24:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24495: tail -F does not terminate when running out of names to watch Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 21 Sep 2016 18:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24495 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Julian =?UTF-8?Q?B=C3=BCning?= , 24495@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 24495-submit@debbugs.gnu.org id=B24495.14744817686091 (code B ref 24495); Wed, 21 Sep 2016 18:17:02 +0000 Received: (at 24495) by debbugs.gnu.org; 21 Sep 2016 18:16:08 +0000 Received: from localhost ([127.0.0.1]:59889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmm3z-0001aB-Og for submit@debbugs.gnu.org; Wed, 21 Sep 2016 14:16:08 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:40868) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmm3x-0001Zp-KB for 24495@debbugs.gnu.org; Wed, 21 Sep 2016 14:16:06 -0400 Received: from [192.168.1.80] (unknown [109.78.255.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 7535812A; Wed, 21 Sep 2016 19:16:01 +0100 (IST) References: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> Date: Wed, 21 Sep 2016 19:15:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> Content-Type: multipart/mixed; boundary="------------CB3623508A01A11FF112304C" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------CB3623508A01A11FF112304C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 21/09/16 15:22, Julian Büning wrote: > observed behavior: > > $ mkdir foo > $ tail -F foo & > [1] 1000 > tail: error reading 'foo': Is a directory > tail: foo: cannot follow end of this type of file; giving up on this name > $ rmdir foo ; echo moo > foo > $ jobs > [1]+ Running tail -F foo & > > expected behavior option 1: > > $ mkdir foo > $ tail -F foo & > tail: error reading 'foo': Is a directory > tail: foo: cannot follow end of this type of file; giving up on this name > $ rmdir foo ; echo moo > foo > [1]+ Done tail -F foo & > > expected behavior option 2: > > $ mkdir foo > $ tail -F foo & > [1] 1000 > tail: error reading 'foo': Is a directory > tail: foo: cannot follow end of this type of file > $ rmdir foo ; echo moo > foo > tail: 'foo' has appeared; following new file > moo > $ jobs > [1]+ Running tail -F foo & > > tail does neither terminate nor display any contents of the file foo. > We would assume that either tail terminates after displaying the error > message (because there is no other file left) or that tail would > infinitely retry to read a file with the same name and if such a file > is created. > > We could reproduce this behavior with versions 8.25 on ArchLinux and > 8.25 and 8.25.71-1db94 on Fedora (package and compiled from source) > with and without ---disable-inotify. At least in version 8.25, > tail_forever_inotify is not executed because any_non_remote_file > returns false, which disables inotify in line 2361 (tail.c). > > We can trace the cause of this behavior for the non-inotify version of > tail_forever: > For a directory, the ignore flag in the corresponding struct File_spec > is set to true. Thus, tail_forever skips this file in line 1130 (tail.c) > and does not modify this flag during any iteration of the enclosing > while(1). Since no check is being done if any valid target remains, > this leads to the observed non-terminating behavior. > > This behavior was found using Symbolic Execution techniques developed in > the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen > University. We can get expected behavior option 1 with the attached patch. Note that's inconsistent with current inotify behavior which does _not_ actually give up on the name, as can be seen when starting with a (non existent) file: $ touch foo $ tail -F foo& [1] 13624 $ rm foo; mkdir foo tail: ‘foo’ has become inaccessible: No such file or directory tail: ‘foo’ has been replaced with an untailable file; giving up on this name $ rmdir foo; echo foo > foo tail: ‘foo’ has become inaccessible: No such file or directory tail: ‘foo’ has appeared; following new file foo The attached patch also removes the "; giving up on this name" message in the inotify case as that's not the case. Ideally we'd have expected behavior option 2 both with and without inotify. I'll need to look a bit more as to why we have that limitation without inotify. I'll add a test case before applying anything. thanks, Pádraig --------------CB3623508A01A11FF112304C Content-Type: text/x-patch; name="tail-retry-exit.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="tail-retry-exit.patch" =46rom e547e9d2122c35c8a48fce3504ee96eac423f7e5 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?P=3DC3=3DA1draig=3D20Brady?=3D Date: Wed, 21 Sep 2016 18:42:40 +0100 Subject: [PATCH] tail: with -F exit if all files are ignored Note ignoring of files is only effective when inotify is not used, so we only exit in that case. * src/tail.c (any_live_files): Change to return false when, all files are ignored, and inotify is not used. Note ignoring of files is only effective when inotify is not used. (recheck): Don't output the "giving up on name" message when inotify is used, as that limitation is only applicable when inotify isn't used. NEWS: Mention the fix. Fixes http://bugs.gnu.org/24495 --- NEWS | 3 +++ src/tail.c | 38 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index beba774..44a2489 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,9 @@ GNU coreutils NEWS -= *- outline -*- seq now immediately exits upon write errors. [This bug was present in "the beginning".] =20 + tail now exits when there are no more files to process and notify is n= ot used. + [bug introduced in coreutils-8.22] + yes now handles short writes, rather than assuming all writes complete= =2E [bug introduced in coreutils-8.24] =20 diff --git a/src/tail.c b/src/tail.c index caa5407..f0a23d8 100644 --- a/src/tail.c +++ b/src/tail.c @@ -956,8 +956,8 @@ recheck (struct File_spec *f, bool blocking) f->errnum =3D -1; f->ignore =3D true; =20 - error (0, 0, _("%s has been replaced with a symbolic link. " - "giving up on this name"), quoteaf (pretty_name (f)= )); + error (0, 0, _("%s has been replaced with a symbolic link"), + quoteaf (pretty_name (f))); } else if (fd =3D=3D -1 || fstat (fd, &new_stats) < 0) { @@ -986,17 +986,17 @@ recheck (struct File_spec *f, bool blocking) { ok =3D false; f->errnum =3D -1; - error (0, 0, _("%s has been replaced with an untailable file;\ - giving up on this name"), - quoteaf (pretty_name (f))); + error (0, 0, _("%s has been replaced with an untailable file%s"), + quoteaf (pretty_name (f)), + disable_inotify ? _("; giving up on this name") : ""); f->ignore =3D true; } else if (!disable_inotify && fremote (fd, pretty_name (f))) { ok =3D false; f->errnum =3D -1; - error (0, 0, _("%s has been replaced with a remote file. " - "giving up on this name"), quoteaf (pretty_name (f)= )); + error (0, 0, _("%s has been replaced with a remote file"), + quoteaf (pretty_name (f))); f->ignore =3D true; f->remote =3D true; } @@ -1075,23 +1075,27 @@ any_live_files (const struct File_spec *f, size_t= n_files) { size_t i; =20 - if (reopen_inaccessible_files && follow_mode =3D=3D Follow_name) + bool all_ignored =3D true; + + /* We retry even ignored files if inotify is available. */ + if (reopen_inaccessible_files && follow_mode =3D=3D Follow_name + && ! disable_inotify) return true; /* continue following for -F option */ =20 for (i =3D 0; i < n_files; i++) { if (0 <=3D f[i].fd) - { - return true; - } + return true; else { - if (reopen_inaccessible_files && follow_mode =3D=3D Follow_des= criptor) - if (! f[i].ignore) - return true; + if (! f[i].ignore) + all_ignored =3D false; } } =20 + if (reopen_inaccessible_files && ! all_ignored) + return true; /* continue following for --retry option */ + return false; } =20 @@ -1930,9 +1934,9 @@ tail_file (struct File_spec *f, uintmax_t n_units) } else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) { - error (0, 0, _("%s: cannot follow end of this type of file= ;\ - giving up on this name"), - quotef (pretty_name (f))); + error (0, 0, _("%s: cannot follow end of this type of file= %s"), + quotef (pretty_name (f)), + disable_inotify ? _("; giving up on this name") : "= "); ok =3D false; f->errnum =3D -1; f->ignore =3D true; --=20 2.5.5 --------------CB3623508A01A11FF112304C-- From unknown Fri Jun 13 11:24:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24495: tail -F does not terminate when running out of names to watch Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 27 Sep 2016 20:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24495 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , Julian =?UTF-8?Q?B=C3=BCning?= , 24495@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 24495-submit@debbugs.gnu.org id=B24495.147500742918276 (code B ref 24495); Tue, 27 Sep 2016 20:18:02 +0000 Received: (at 24495) by debbugs.gnu.org; 27 Sep 2016 20:17:09 +0000 Received: from localhost ([127.0.0.1]:37453 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boyoP-0004kh-8o for submit@debbugs.gnu.org; Tue, 27 Sep 2016 16:17:09 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:58449) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boyoO-0004kV-A1 for 24495@debbugs.gnu.org; Tue, 27 Sep 2016 16:17:08 -0400 Received: from [192.168.101.10] ([217.86.86.51]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MBkiF-1bh2a62QFj-00AqD4; Tue, 27 Sep 2016 22:16:57 +0200 References: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> From: Bernhard Voelker Message-ID: <1f4ec7f7-e9c7-fa19-1c7c-e0cde2f09134@bernhard-voelker.de> Date: Tue, 27 Sep 2016 22:16:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:wKVsOgIkyE3neS+A3iSz6kACBS5ccZQf55wcaI8QmqD/Td0TC2d IGdhu9BKk+S1aUlzsyYAusziXXO15zBAgoyzm4+b/DUFGgD5PMrMGt+XMM2CzeuLqg+fcqT C7KX0sQUGAp2y0hxHtzMQ+C6pDBdpVqgTfV8UDQPIqBZV5LpZw5je39E7NPqJ67aIXYwRN+ v1cPy+PMgcy2TdS1s2C0g== X-UI-Out-Filterresults: notjunk:1;V01:K0:JoqxTovi4nY=:XzNibqK7W+zW5gkSfTKv8a u8kAkdQ5Kc6tfL3jEfWpFw5okH+U8SYo98i9RJlfAVePBgQoVGXKmwUUVr1znrV66KPNFDdgc YN6wPTzlPVtuqy290iClsHOTfVkj7U7uWD1dKbY4WzVtquQCSnlIXMMFQ5N9lMv5tIfBrME2X 640BzJJ7urx5nCWTz6VZU4GyVU2DD8BLjPvRP2TJtf3s6AkpNsF97OJGiDQVTq+7e0TChYdrj xY1KUEI0BrZcrSDTmMpmdqhvOnzIzlv2DyGZiFFuRZW2nAwcxxUot10UTRU5qZqcydLaEgbUg 4oVV0CpWbkS/KODQW9+c4yBlaUDAreQr2rMFL+7K/g7KrjjNGgGZBnNghRQJf1YxsMW8iaZT6 VFBcB8GdYDgc5hPoqIdB+kqZXLRr9CV7wNTtNeiCCjhnkW0Vtnw7h6OFpYr1ZI5yU9wDnCqYk 0DP98zotBOZM+FuN7rp5XSahMCDw+8l3E/L3f5xdAwiZKODKQpHJ8wsJ5c8rvPZ0yOUtQuxWl 8zFP3CurBX2YDj+H8d8IEx1JC9rvbKN5DF/yN0DZ1Jmxd6YD1c5BZco9SPflCXyGkiHvBMV+C pJ+UwvQCqXFGRmIIDGLgQwr1q0X4xGLD9cjzjpF6M/zbLs1Q1iQMVTj6TVV4e97cJ/j3OsYe+ PYy/TBHWIPaBr1Yd1vuOFJQn3veeBORIkITXnbVQcj1soMxc6z6m6UZ3u29kdJP668tzPg1pr dw9J0M5lq3B7QJq+ X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 09/21/2016 08:15 PM, Pádraig Brady wrote: > We can get expected behavior option 1 with the attached patch. > Note that's inconsistent with current inotify behavior which does > _not_ actually give up on the name, as can be seen when starting > with a (non existent) file: > > $ touch foo > $ tail -F foo& > [1] 13624 > $ rm foo; mkdir foo > tail: ‘foo’ has become inaccessible: No such file or directory > tail: ‘foo’ has been replaced with an untailable file; giving up on this name > $ rmdir foo; echo foo > foo > tail: ‘foo’ has become inaccessible: No such file or directory > tail: ‘foo’ has appeared; following new file > foo > > The attached patch also removes the "; giving up on this name" > message in the inotify case as that's not the case. > > Ideally we'd have expected behavior option 2 > both with and without inotify. > I'll need to look a bit more as to why we have that > limitation without inotify. The new behavior is nice, but it would really be better to have consistent behavior in inotify and polling mode. Thanks & have a nice day, Berny From unknown Fri Jun 13 11:24:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24495: tail -F does not terminate when running out of names to watch Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 28 Sep 2016 13:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24495 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bernhard Voelker , Julian =?UTF-8?Q?B=C3=BCning?= , 24495@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 24495-submit@debbugs.gnu.org id=B24495.147506926820890 (code B ref 24495); Wed, 28 Sep 2016 13:28:01 +0000 Received: (at 24495) by debbugs.gnu.org; 28 Sep 2016 13:27:48 +0000 Received: from localhost ([127.0.0.1]:37691 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpEtn-0005Qs-Px for submit@debbugs.gnu.org; Wed, 28 Sep 2016 09:27:48 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:39750) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpEtk-0005Qi-UL for 24495@debbugs.gnu.org; Wed, 28 Sep 2016 09:27:46 -0400 Received: from [192.168.1.80] (unknown [109.76.85.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 2A44F16F; Wed, 28 Sep 2016 14:27:43 +0100 (IST) References: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> <1f4ec7f7-e9c7-fa19-1c7c-e0cde2f09134@bernhard-voelker.de> From: =?UTF-8?Q?P=C3=A1draig?= Brady Message-ID: <87770ca1-d594-d806-c008-0b5435a84204@draigBrady.com> Date: Wed, 28 Sep 2016 14:27:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1f4ec7f7-e9c7-fa19-1c7c-e0cde2f09134@bernhard-voelker.de> Content-Type: multipart/mixed; boundary="------------DCEC94223585C820356C0647" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------DCEC94223585C820356C0647 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 27/09/16 21:16, Bernhard Voelker wrote: > On 09/21/2016 08:15 PM, Pádraig Brady wrote: >> We can get expected behavior option 1 with the attached patch. >> Note that's inconsistent with current inotify behavior which does >> _not_ actually give up on the name, as can be seen when starting >> with a (non existent) file: >> >> $ touch foo >> $ tail -F foo& >> [1] 13624 >> $ rm foo; mkdir foo >> tail: ‘foo’ has become inaccessible: No such file or directory >> tail: ‘foo’ has been replaced with an untailable file; giving up on this name >> $ rmdir foo; echo foo > foo >> tail: ‘foo’ has become inaccessible: No such file or directory >> tail: ‘foo’ has appeared; following new file >> foo >> >> The attached patch also removes the "; giving up on this name" >> message in the inotify case as that's not the case. >> >> Ideally we'd have expected behavior option 2 >> both with and without inotify. >> I'll need to look a bit more as to why we have that >> limitation without inotify. > > The new behavior is nice, but it would really be better to have > consistent behavior in inotify and polling mode. Yes consistency would be nice. Looking at the polling behavior I see it was not fundamental to the initial implementation and only changed later: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=FILEUTILS-4_0q-68-g54d12f7 The attached patch how has the preferred behavior option 2 both with and without inotify. thanks, Pádraig --------------DCEC94223585C820356C0647 Content-Type: text/x-patch; name="tail-retry-exit.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="tail-retry-exit.patch" =46rom d76beda19d6c181915bb5323a19d965b899b20dc Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?P=3DC3=3DA1draig=3D20Brady?=3D Date: Wed, 21 Sep 2016 18:42:40 +0100 Subject: [PATCH] tail: -F now always processes initially untailable files= This was not the case when inotify was not available. * src/tail.c (any_live_files): Simplify, since the IGNORE flag is now only set when a file should be ignored indefinitely. (recheck): Only output the "giving up on name" message when that's actually the case. Only set the IGNORE flag when ignoring a file indefinitely. (tail_file): Likewise. * tests/tail-2/retry.sh: Add a test case. Also run all existing test cases with and without inotify. NEWS: Mention the fix. Fixes http://bugs.gnu.org/24495 --- NEWS | 5 +++++ src/tail.c | 41 ++++++++++++++++++++--------------------- tests/tail-2/retry.sh | 34 +++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/NEWS b/NEWS index beba774..c3554d0 100644 --- a/NEWS +++ b/NEWS @@ -42,6 +42,11 @@ GNU coreutils NEWS = -*- outline -*- seq now immediately exits upon write errors. [This bug was present in "the beginning".] =20 + tail -F now continues to process initially untailable files that are r= eplaced + by a tailable file. This was handled correctly when inotify was avail= able, + and is now handled correctly in all cases. + [bug introduced in fileutils-4.0h] + yes now handles short writes, rather than assuming all writes complete= =2E [bug introduced in coreutils-8.24] =20 diff --git a/src/tail.c b/src/tail.c index caa5407..c2982f5 100644 --- a/src/tail.c +++ b/src/tail.c @@ -956,8 +956,8 @@ recheck (struct File_spec *f, bool blocking) f->errnum =3D -1; f->ignore =3D true; =20 - error (0, 0, _("%s has been replaced with a symbolic link. " - "giving up on this name"), quoteaf (pretty_name (f)= )); + error (0, 0, _("%s has been replaced with a symbolic link"), + quoteaf (pretty_name (f))); } else if (fd =3D=3D -1 || fstat (fd, &new_stats) < 0) { @@ -986,17 +986,20 @@ recheck (struct File_spec *f, bool blocking) { ok =3D false; f->errnum =3D -1; - error (0, 0, _("%s has been replaced with an untailable file;\ - giving up on this name"), - quoteaf (pretty_name (f))); - f->ignore =3D true; + f->tailable =3D false; + if (! (reopen_inaccessible_files && follow_mode =3D=3D Follow_name= )) + f->ignore =3D true; + if (was_tailable || prev_errnum !=3D f->errnum) + error (0, 0, _("%s has been replaced with an untailable file%s")= , + quoteaf (pretty_name (f)), + f->ignore ? _("; giving up on this name") : ""); } else if (!disable_inotify && fremote (fd, pretty_name (f))) { ok =3D false; f->errnum =3D -1; - error (0, 0, _("%s has been replaced with a remote file. " - "giving up on this name"), quoteaf (pretty_name (f)= )); + error (0, 0, _("%s has been replaced with a remote file"), + quoteaf (pretty_name (f))); f->ignore =3D true; f->remote =3D true; } @@ -1075,20 +1078,14 @@ any_live_files (const struct File_spec *f, size_t= n_files) { size_t i; =20 - if (reopen_inaccessible_files && follow_mode =3D=3D Follow_name) - return true; /* continue following for -F option */ - for (i =3D 0; i < n_files; i++) { if (0 <=3D f[i].fd) - { - return true; - } + return true; else { - if (reopen_inaccessible_files && follow_mode =3D=3D Follow_des= criptor) - if (! f[i].ignore) - return true; + if (! f[i].ignore && reopen_inaccessible_files) + return true; } } =20 @@ -1930,12 +1927,14 @@ tail_file (struct File_spec *f, uintmax_t n_units= ) } else if (!IS_TAILABLE_FILE_TYPE (stats.st_mode)) { - error (0, 0, _("%s: cannot follow end of this type of file= ;\ - giving up on this name"), - quotef (pretty_name (f))); ok =3D false; f->errnum =3D -1; - f->ignore =3D true; + f->tailable =3D false; + f->ignore =3D ! (reopen_inaccessible_files + && follow_mode =3D=3D Follow_name); + error (0, 0, _("%s: cannot follow end of this type of file= %s"), + quotef (pretty_name (f)), + f->ignore ? _("; giving up on this name") : ""); } =20 if (!ok) diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh index 37e01ed..a4cff11 100755 --- a/tests/tail-2/retry.sh +++ b/tests/tail-2/retry.sh @@ -55,11 +55,14 @@ tail --retry missing > out 2>&1 && fail=3D1 [ "$(countlines_)" =3D 2 ] || { cat out; fail=3D1; }= grep -F 'tail: warning: --retry ignored' out || { cat out; fail=3D1; } =20 +for mode in '' '---disable-inotify'; do + # =3D=3D=3D Test: # Ensure that "tail --retry --follow=3Dname" waits for the file to appea= r. # Clear 'out' so that we can check its contents without races >out || framework_failure_ -timeout 10 tail $fastpoll --follow=3Dname --retry missing >out 2>&1 & pi= d=3D$! +timeout 10 \ + tail $mode $fastpoll --follow=3Dname --retry missing >out 2>&1 & pid=3D= $! # Wait for "cannot open" error. retry_delay_ wait4lines_ .1 6 1 || { cat out; fail=3D1; } echo "X" > missing || framework_failure_ @@ -76,7 +79,8 @@ rm -f missing out || framework_failure_ # =3D=3D=3D Test: # Ensure that "tail --retry --follow=3Ddescriptor" waits for the file to= appear. # tail-8.21 failed at this (since the implementation of the inotify supp= ort). -timeout 10 tail $fastpoll --follow=3Ddescriptor --retry missing >out 2>&= 1 & pid=3D$! +timeout 10 \ + tail $mode $fastpoll --follow=3Ddescriptor --retry missing >out 2>&1 &= pid=3D$! # Wait for "cannot open" error. retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=3D1; } echo "X" > missing || framework_failure_ @@ -95,7 +99,8 @@ rm -f missing out || framework_failure_ # =3D=3D=3D Test: # Ensure that tail --follow=3Ddescriptor --retry exits when the file app= ears # untailable. Expect exit status 1. -timeout 10 tail $fastpoll --follow=3Ddescriptor --retry missing >out 2>&= 1 & pid=3D$! +timeout 10 \ + tail $mode $fastpoll --follow=3Ddescriptor --retry missing >out 2>&1 &= pid=3D$! # Wait for "cannot open" error. retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=3D1; } mkdir missing || framework_failure_ # Create untailab= le @@ -116,16 +121,35 @@ rm -fd missing out || f= ramework_failure_ # Ensure that --follow=3Ddescriptor (without --retry) does *not wait* fo= r the # file to appear. Expect 2 lines in the output file ("cannot open" + # "no files remaining") and exit status 1. -tail --follow=3Ddescriptor missing >out 2>&1 && fail=3D1 +tail $mode --follow=3Ddescriptor missing >out 2>&1 && fail=3D1 [ "$(countlines_)" =3D 2 ] || { fail=3D1; cat out; } grep -F 'cannot open' out || { fail=3D1; cat out; } grep -F 'no files remaining' out || { fail=3D1; cat out; } =20 # =3D=3D=3D Test: # Likewise for --follow=3Dname (without --retry). -tail --follow=3Dname missing >out 2>&1 && fail=3D1 +tail $mode --follow=3Dname missing >out 2>&1 && fail=3D1 [ "$(countlines_)" =3D 2 ] || { fail=3D1; cat out; } grep -F 'cannot open' out || { fail=3D1; cat out; } grep -F 'no files remaining' out || { fail=3D1; cat out; } =20 +# =3D=3D=3D Test: +# Ensure that tail -F retries when the file is initally untailable. +mkdir untailable +timeout 10 \ + tail $mode $fastpoll -F untailable >out 2>&1 & pid=3D$! +# Wait for "cannot open" error. +retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=3D1; } +{ rmdir untailable; echo foo > untailable; } || framework_failure_ +# Wait for the expected output. +retry_delay_ wait4lines_ .1 6 4 || { cat out; fail=3D1; } +cleanup_ +[ "$(countlines_)" =3D 4 ] || { fail=3D1; cat out;= } +grep -F 'cannot follow' out || { fail=3D1; cat out; }= +grep -F 'has become accessible' out || { fail=3D1; cat out; }= +grep -F 'foo' out || { fail=3D1; cat out; }= +rm -fd untailable out || framework_failure_ + +done + Exit $fail --=20 2.5.5 --------------DCEC94223585C820356C0647-- From unknown Fri Jun 13 11:24:40 2025 X-Loop: help-debbugs@gnu.org Subject: bug#24495: tail -F does not terminate when running out of names to watch Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 28 Sep 2016 21:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24495 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady , Julian =?UTF-8?Q?B=C3=BCning?= , 24495@debbugs.gnu.org Cc: Oscar Soria Dustmann , Daniel Schemmel Received: via spool by 24495-submit@debbugs.gnu.org id=B24495.147509868332672 (code B ref 24495); Wed, 28 Sep 2016 21:39:01 +0000 Received: (at 24495) by debbugs.gnu.org; 28 Sep 2016 21:38:03 +0000 Received: from localhost ([127.0.0.1]:38259 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpMYF-0008Ut-Gv for submit@debbugs.gnu.org; Wed, 28 Sep 2016 17:38:03 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:58081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpMYD-0008UQ-UE for 24495@debbugs.gnu.org; Wed, 28 Sep 2016 17:38:02 -0400 Received: from [192.168.101.10] ([217.86.86.51]) by mrelayeu.kundenserver.de (mreue002) with ESMTPSA (Nemesis) id 0MSmRQ-1bNu450y1s-00RWl4; Wed, 28 Sep 2016 23:37:53 +0200 References: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> <1f4ec7f7-e9c7-fa19-1c7c-e0cde2f09134@bernhard-voelker.de> <87770ca1-d594-d806-c008-0b5435a84204@draigBrady.com> From: Bernhard Voelker Message-ID: <1ecceac3-b6d2-8e05-0066-ad80411b0b68@bernhard-voelker.de> Date: Wed, 28 Sep 2016 23:37:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <87770ca1-d594-d806-c008-0b5435a84204@draigBrady.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:95Ms3Zlhi6WTyLUF0cjlmO1cO+5ERgedRm5NzDmtmxxX07uOvku C5LSyNSkt0qaJQuCLv0laJg0NVyPimQvNraD1ryXwFI7CuyAfGOksg1Pij0BXuYEvZRlJOE AxEZW64ECc5aHpKwPYhRrPdfwQlF0pG1oJgRK8sXIyp5NKItkTIKl8nYJ3ekl6A4d2YH5s2 TWAkTPGwBXc9YQxgRvJRA== X-UI-Out-Filterresults: notjunk:1;V01:K0:OEilnRDdeCk=:mGSreJglm63wCX4XDHC4zH cFPTJ/0S+zWK19ECKqACzwUD73De+2Iscjz/XABOSOFIKdTkaym6gwbWn7Y/Uti+SJ38pWqGa qeWwMyUKGQoHFUUCudvz6mLVcoT1FM5FZQr9MSeam5hE5YWnau63RyeiP0PBUFXxEKMcJ+uHE +sMoIMZAh2ZQqlTbCHhGHqTKbg3An6m+UWqPPYfpAeFCr5jQE21dSHSSQm1+aj736SnMDU5t2 PwfC5/SC4DLEtR5G8Mo7gRs7OSnxo8yOhywbJBw+XiQFVy9Q1xtOsnf1jjKrraWn3yZszrvei mGBHrA/ka7CVs9/0wFcWxcbw6AUw/sQO4LUpN0lNix0VhM4pWBVoQYA18K+3whWF6XKn/pVJC sKvSud4EXj92OdQemtSDOmyE9PyJLvwFVWntlruFoRR4oxEXufF+beE17bBKXEnJ+dh3gY/RD ck2gM1uuHvzeudJ5FZpjXjm9Z95edT9obc4Rt8SFk70w+2bREzwWgcxHBiF+QS1dugMrUkk8p Odu+mENkKfHrBKZ6YeVDnCOMGWMnig+QItYmVYhPh0439U9r6NAI9s17vxiPw+aj+URXI8PH+ 4gq8IvTLCEQA4WiZ+hQi/PsluzKG7ymH+yxy2h/Qg5HyRict+3Pu/pbCqit4WeiSRXB2/PXRy uz1rH9DSbln5ekod/FadL8vNuHlS3pX/itA/GSYxUP6nffcPXNpLTDOOaD/Q6leX6xtZqnnam RuM/AP7NahCTeGtB X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 09/28/2016 03:27 PM, Pádraig Brady wrote: > The attached patch how has the preferred behavior option 2 > both with and without inotify. Great, this looks good to me. +1 Thanks & have a nice day, Berny From unknown Fri Jun 13 11:24:40 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Julian =?UTF-8?Q?B=C3=BCning?= Subject: bug#24495: closed (Re: bug#24495: tail -F does not terminate when running out of names to watch) Message-ID: References: <0ac67874-6273-aaa5-fedb-5743b739d4fb@draigBrady.com> <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> X-Gnu-PR-Message: they-closed 24495 X-Gnu-PR-Package: coreutils Reply-To: 24495@debbugs.gnu.org Date: Wed, 28 Sep 2016 22:44:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1475102642-12272-1" This is a multi-part message in MIME format... ------------=_1475102642-12272-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #24495: tail -F does not terminate when running out of names to watch which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 24495@debbugs.gnu.org. --=20 24495: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D24495 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1475102642-12272-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 24495-done) by debbugs.gnu.org; 28 Sep 2016 22:43:31 +0000 Received: from localhost ([127.0.0.1]:38287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpNZb-0003B4-Ks for submit@debbugs.gnu.org; Wed, 28 Sep 2016 18:43:31 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:41748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpNZZ-0003Av-An for 24495-done@debbugs.gnu.org; Wed, 28 Sep 2016 18:43:29 -0400 Received: from [192.168.1.80] (unknown [109.76.85.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id 9AA6416F; Wed, 28 Sep 2016 23:43:26 +0100 (IST) Subject: Re: bug#24495: tail -F does not terminate when running out of names to watch To: Bernhard Voelker , =?UTF-8?Q?Julian_B=c3=bcning?= , 24495-done@debbugs.gnu.org References: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> <776368d2-dff8-d4d7-7c65-f9886c3757c7@draigBrady.com> <1f4ec7f7-e9c7-fa19-1c7c-e0cde2f09134@bernhard-voelker.de> <87770ca1-d594-d806-c008-0b5435a84204@draigBrady.com> <1ecceac3-b6d2-8e05-0066-ad80411b0b68@bernhard-voelker.de> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: <0ac67874-6273-aaa5-fedb-5743b739d4fb@draigBrady.com> Date: Wed, 28 Sep 2016 23:43:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1ecceac3-b6d2-8e05-0066-ad80411b0b68@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 24495-done Cc: Oscar Soria Dustmann , Daniel Schemmel X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 28/09/16 22:37, Bernhard Voelker wrote: > On 09/28/2016 03:27 PM, Pádraig Brady wrote: >> The attached patch how has the preferred behavior option 2 >> both with and without inotify. > > Great, this looks good to me. > +1 Thanks for the reviews. Pushed at: http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.25-73-gf04daf5 Marking this as done ------------=_1475102642-12272-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 21 Sep 2016 15:39:41 +0000 Received: from localhost ([127.0.0.1]:59724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmjcb-0002iJ-G0 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 11:39:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60413) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmiP0-0007ZV-89 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmiOu-00046T-72 for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOu-00046L-3Q for submit@debbugs.gnu.org; Wed, 21 Sep 2016 10:21:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOr-0004A7-Sg for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmiOm-00045F-RC for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:25 -0400 Received: from mx-out-2.rwth-aachen.de ([134.130.5.187]:43569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmiOm-00044n-JQ for bug-coreutils@gnu.org; Wed, 21 Sep 2016 10:21:20 -0400 X-IronPort-AV: E=Sophos;i="5.30,373,1470693600"; d="scan'208";a="459219666" Received: from rwthex-s1-a.rwth-ad.de ([134.130.26.152]) by mx-2.rz.rwth-aachen.de with ESMTP; 21 Sep 2016 16:21:19 +0200 Received: from [134.61.86.206] (134.61.86.206) by rwthex-s1-a.rwth-ad.de (2002:8682:1a98::8682:1a98) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 21 Sep 2016 16:21:18 +0200 To: From: =?UTF-8?Q?Julian_B=c3=bcning?= Subject: tail -F does not terminate when running out of names to watch Date: Wed, 21 Sep 2016 16:22:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [134.61.86.206] X-ClientProxiedBy: rwthex-s2-b.rwth-ad.de (2002:8682:1a9b::8682:1a9b) To rwthex-s1-a.rwth-ad.de (2002:8682:1a98::8682:1a98) Message-ID: <7ae86ee7bd6a417297a7162466369b7b@rwthex-s1-a.rwth-ad.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 21 Sep 2016 11:39:40 -0400 Cc: Oscar Soria Dustmann , Daniel Schemmel X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) observed behavior: $ mkdir foo $ tail -F foo & [1] 1000 tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file; giving up on this name $ rmdir foo ; echo moo > foo $ jobs [1]+ Running tail -F foo & expected behavior option 1: $ mkdir foo $ tail -F foo & tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file; giving up on this name $ rmdir foo ; echo moo > foo [1]+ Done tail -F foo & expected behavior option 2: $ mkdir foo $ tail -F foo & [1] 1000 tail: error reading 'foo': Is a directory tail: foo: cannot follow end of this type of file $ rmdir foo ; echo moo > foo tail: 'foo' has appeared; following new file moo $ jobs [1]+ Running tail -F foo & tail does neither terminate nor display any contents of the file foo. We would assume that either tail terminates after displaying the error message (because there is no other file left) or that tail would infinitely retry to read a file with the same name and if such a file is created. We could reproduce this behavior with versions 8.25 on ArchLinux and 8.25 and 8.25.71-1db94 on Fedora (package and compiled from source) with and without ---disable-inotify. At least in version 8.25, tail_forever_inotify is not executed because any_non_remote_file returns false, which disables inotify in line 2361 (tail.c). We can trace the cause of this behavior for the non-inotify version of tail_forever: For a directory, the ignore flag in the corresponding struct File_spec is set to true. Thus, tail_forever skips this file in line 1130 (tail.c) and does not modify this flag during any iteration of the enclosing while(1). Since no check is being done if any valid target remains, this leads to the observed non-terminating behavior. This behavior was found using Symbolic Execution techniques developed in the course of the SYMBIOSYS research project at COMSYS, RWTH Aachen University. Regards, Julian Büning ------------=_1475102642-12272-1--