diff options
| author | Pádraig Brady <P@draigBrady.com> | 2026-05-16 18:55:42 +0100 |
|---|---|---|
| committer | Pádraig Brady <P@draigBrady.com> | 2026-05-16 23:01:16 +0100 |
| commit | a6ba6a23ad9488528f201a45200d317600447a05 (patch) | |
| tree | f75ba5cffb70fbef23625d9a9246e15090d65530 /tests | |
| parent | 7d2b55102d3fd647525b77b4153dcb3245015d07 (diff) | |
| download | coreutils-master.tar.gz coreutils-master.zip | |
* tests/tail/pid-pipe.sh: Ensure not only open() is
handled asynchronously with --pid.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/tail/pid-pipe.sh | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/tests/tail/pid-pipe.sh b/tests/tail/pid-pipe.sh index b87b6ab28..b4a964e3a 100755 --- a/tests/tail/pid-pipe.sh +++ b/tests/tail/pid-pipe.sh @@ -21,16 +21,55 @@ print_ver_ tail mkfifo_or_skip_ fifo + # Terminate any background process -cleanup_() { kill $pid 2>/dev/null && wait $pid; } +cleanup_() +{ + for p in $pid $writer_pid; do + kill $p 2>/dev/null + done + for p in $pid $writer_pid; do + wait $p 2>/dev/null + done + + pid= + writer_pid= +} # Speedup the non inotify case fastpoll='-s.1 --max-unchanged-stats=1' + +# Ensure an absent FIFO writer doesn't block tail from checking --pid. sleep 1 & pid=$! +returns_ 124 timeout 10 tail -f $fastpoll --pid=$pid fifo && fail=1 +cleanup_ + -returns_ 124 timeout 10 tail -f $fastpoll --pid=$! fifo && fail=1 +# Ensure a silent FIFO writer doesn't block tail from checking --pid. +rm -f writer-ready || framework_failure_ +writer_ready_() +{ + sleep $1 + test -e writer-ready +} + +# Simulate a writer that may wait a long time between writes +silent_writer() { + exec 3>fifo && + touch writer-ready && + exec sleep 20 +} +silent_writer & writer_pid=$! + +# allow fifo to open +timeout 10 $SHELL -c ': < fifo' || framework_failure_ +retry_delay_ writer_ready_ .1 6 || framework_failure_ + +sleep 1 & pid=$! +returns_ 124 timeout 10 tail -f $fastpoll --pid=$pid fifo && fail=1 cleanup_ + Exit $fail |
