* tests/tail/pid-pipe.sh: Ensure not only open() is
handled asynchronously with --pid.
---
 tests/tail/pid-pipe.sh | 42 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/tests/tail/pid-pipe.sh b/tests/tail/pid-pipe.sh
index b87b6ab28..0932bbdbf 100755
--- a/tests/tail/pid-pipe.sh
+++ b/tests/tail/pid-pipe.sh
@@ -21,16 +21,54 @@ 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
+}
+
+silent_writer() {
+  exec 3>fifo || exit 1
+  touch writer-ready || exit 1
+  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
-- 
2.54.0


Reply via email to