coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] tail: fix erroneous status about 'giving up' on file


From: Pádraig Brady
Subject: [PATCH 1/2] tail: fix erroneous status about 'giving up' on file
Date: Tue, 31 Jan 2017 21:41:35 -0800

* src/tail.c (recheck): Set f->ignore before we
use it to show the appropriate error.
* tests/tail-2/retry.sh: Ensure the "giving up" message
is not presented.
---
 src/tail.c            | 7 +++----
 tests/tail-2/retry.sh | 3 ++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/tail.c b/src/tail.c
index 3023dd4..0c9c3e8 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -981,8 +981,7 @@ recheck (struct File_spec *f, bool blocking)
       ok = false;
       f->errnum = -1;
       f->tailable = false;
-      if (! (reopen_inaccessible_files && follow_mode == Follow_name))
-        f->ignore = true;
+      f->ignore = ! (reopen_inaccessible_files && follow_mode == Follow_name);
       if (was_tailable || prev_errnum != f->errnum)
         error (0, 0, _("%s has been replaced with an untailable file%s"),
                quoteaf (pretty_name (f)),
@@ -1940,6 +1939,7 @@ tail_file (struct File_spec *f, uintmax_t n_units)
               ok = false;
               f->errnum = -1;
               f->tailable = false;
+              f->ignore = ! reopen_inaccessible_files;
               error (0, 0, _("%s: cannot follow end of this type of file%s"),
                      quotef (pretty_name (f)),
                      f->ignore ? _("; giving up on this name") : "");
@@ -1947,8 +1947,7 @@ tail_file (struct File_spec *f, uintmax_t n_units)
 
           if (!ok)
             {
-              f->ignore = ! (reopen_inaccessible_files
-                             && follow_mode == Follow_name);
+              f->ignore = ! reopen_inaccessible_files;
               close_fd (fd, pretty_name (f));
               f->fd = -1;
             }
diff --git a/tests/tail-2/retry.sh b/tests/tail-2/retry.sh
index b20deb5..40d66d6 100755
--- a/tests/tail-2/retry.sh
+++ b/tests/tail-2/retry.sh
@@ -164,7 +164,7 @@ if ! cat . >/dev/null; then
 mkdir untailable || framework_failure_
 timeout 10 \
   tail $mode $fastpoll -F untailable >out 2>&1 & pid=$!
-# Wait for "cannot open" error.
+# Wait for "cannot follow" error.
 retry_delay_ wait4lines_ .1 6 2 || { cat out; fail=1; }
 { rmdir untailable; echo foo > untailable; }   || framework_failure_
 # Wait for the expected output.
@@ -173,6 +173,7 @@ cleanup_
 [ "$(countlines_)" = 4 ]                       || { fail=1; cat out; }
 grep -F 'cannot follow' out                    || { fail=1; cat out; }
 grep -F 'has become accessible' out            || { fail=1; cat out; }
+grep -F 'giving up'             out            && { fail=1; cat out; }
 grep -F 'foo' out                              || { fail=1; cat out; }
 rm -fd untailable out                          || framework_failure_
 fi
-- 
2.5.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]