copy: copy_file_range: handle ENOENT for CIFS
[coreutils.git] / tests / tail-2 / pipe-f.sh
blob61812d1aa068b6051c8505ec7a724039d5ce0d73
1 #!/bin/sh
2 # ensure that tail -f doesn't hang in various cases
4 # Copyright (C) 2009-2023 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ tail test head
21 trap_sigpipe_or_skip_
23 # Speedup the non inotify case
24 fastpoll='-s.1 --max-unchanged-stats=1'
26 for mode in '' '---disable-inotify'; do
27 # Ensure :|tail -f doesn't hang, per POSIX
28 echo oo > exp || framework_failure_
29 echo foo | timeout 10 tail -f $mode $fastpoll -c3 > out || fail=1
30 compare exp out || fail=1
31 cat <<\EOF > exp || framework_failure_
32 ==> standard input <==
34 EOF
35 echo bar | returns_ 1 \
36 timeout 10 tail -f $mode $fastpoll -c3 - missing > out || fail=1
37 compare exp out || fail=1
39 # This would wait indefinitely before v8.28 due to no EPIPE being
40 # generated due to no data written after the first small amount.
41 # Also check tail exits if SIGPIPE is being ignored.
42 # Note 'trap - SIGPIPE' is ineffective if the initiating shell
43 # has ignored SIGPIPE, but that's not the normal case.
44 for disposition in '' '-'; do
45 (trap "$disposition" PIPE;
46 returns_ 124 timeout 10 \
47 tail -n2 -f $mode $fastpoll out && touch timed_out) |
48 head -n2 > out2
49 test -e timed_out && fail=1
50 compare exp out2 || fail=1
51 rm -f timed_out
52 done
54 # This would wait indefinitely before v8.28 (until first write)
55 # test -w /dev/stdout is used to check that >&- is effective
56 # which was seen not to be the case on NetBSD 7.1 / x86_64:
57 if env test -w /dev/stdout >/dev/null &&
58 env test ! -w /dev/stdout >&-; then
59 (returns_ 1 timeout 10 tail -f $mode $fastpoll /dev/null >&-) || fail=1
61 done
63 Exit $fail