tests: tail-2/flush-initial: correct race avoidance code
authorJim Meyering <meyering@redhat.com>
Sun, 6 Sep 2009 18:00:14 +0000 (20:00 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 6 Sep 2009 18:00:34 +0000 (20:00 +0200)
* tests/tail-2/flush-initial: Wait for the file to be nonempty,
not for the process.  Based on a suggestion from Pádraig Brady.

tests/tail-2/flush-initial

index 2deff84..515b29d 100755 (executable)
@@ -28,9 +28,10 @@ echo line > in || fail=1
 stdbuf --output=1K tail -f in > out &
 tail_pid=$!
 
-# Wait for the backgrounded `tail' to start.
-while :; do
-  env kill -0 $tail_pid && break
+# Wait for 1 second for the file to be flushed.
+for i in $(seq 10); do
+  test -s out && break
+  echo sleep .1s
   sleep .1
 done