tail: always fail when followed files become inaccessible

* src/tail.c (tail_forever): Without --retry, exit with failure
status like we do for the inotify case (since v8.11-15-g61de57cd2).
This is also consistent with the failure exit if no file was
accessible at tail startup.
* tests/tail/follow-stdin.sh: Tweak due to earlier exit.
* tests/tail/follow-name.sh: Test with and without inotify.
* NEWS: Mention the bug fix.
This commit is contained in:
Pádraig Brady
2024-12-20 14:28:11 +00:00
parent c8bb7afcfb
commit 8b9fa9d074
4 changed files with 18 additions and 10 deletions

View File

@@ -29,14 +29,19 @@ returns_ 1 timeout 10 tail --follow=name no-such > out 2> err || fail=1
sed '/inotify cannot be used/d' err > k && mv k err
compare exp err || fail=1
# Between coreutils 8.34 and 9.5 inclusive, tail would have
# waited indefinitely when a file was moved to the same file system
# Between coreutils 8.34 and 9.5 inclusive, with inotify, tail would
# have waited indefinitely when a file was moved to the same file system.
# Also without inotify tail would have exited with success.
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
touch file || framework_failure_
timeout 10 tail --follow=name file & pid=$!
sleep .1 # Usually in inotify loop here
mv file file.unfollow || framework_failure_
wait $pid
test $? = 1 || fail=1
fastpoll='-s.1 --max-unchanged-stats=1' # speedup non inotify systems
for inotify in '' '---disable-inotify'; do
touch file || framework_failure_
timeout 10 tail --follow=name $fastpoll file & pid=$!
sleep .1 # Usually in tail_forever{,_inotify}() here
mv file file.unfollow || framework_failure_
wait $pid
test $? = 1 || fail=1
rm -f file file.unfollow || framework_failure_
done
Exit $fail

View File

@@ -61,7 +61,6 @@ cat <<\EOF >exp || framework_failure_
tail: cannot fstat 'standard input'
tail: error reading 'standard input'
tail: no files remaining
tail: -
EOF
sed 's/\(tail:.*\):.*/\1/' errt > err || framework_failure_
compare exp err || fail=1