diff options
-rw-r--r-- | src/tail.c | 4 | ||||
-rwxr-xr-x | tests/tail-2/follow-stdin.sh | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/tail.c b/src/tail.c index 5c75be08d..6bf1e77d0 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1940,8 +1940,6 @@ tail_file (struct File_spec *f, uintmax_t n_units) ok = false; f->errnum = -1; f->tailable = false; - f->ignore = ! (reopen_inaccessible_files - && follow_mode == 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") : ""); @@ -1949,6 +1947,8 @@ tail_file (struct File_spec *f, uintmax_t n_units) if (!ok) { + f->ignore = ! (reopen_inaccessible_files + && follow_mode == Follow_name); close_fd (fd, pretty_name (f)); f->fd = -1; } diff --git a/tests/tail-2/follow-stdin.sh b/tests/tail-2/follow-stdin.sh index a2f180428..3d51f6006 100755 --- a/tests/tail-2/follow-stdin.sh +++ b/tests/tail-2/follow-stdin.sh @@ -50,4 +50,16 @@ for mode in '' '---disable-inotify'; do cleanup_ done + +# Before coreutils-8.26 this would induce an UMR under UBSAN +returns_ 1 timeout 10 tail -f - <&- 2>err || fail=1 +cat <<\EOF >exp || framework_failure_ +tail: cannot fstat 'standard input': Bad file descriptor +tail: error reading 'standard input': Bad file descriptor +tail: no files remaining +tail: -: Bad file descriptor +EOF +compare exp err || fail=1 + + Exit $fail |