]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: tail-2/assert: avoid risk of race condition
authorJim Meyering <meyering@redhat.com>
Tue, 25 Aug 2009 18:43:13 +0000 (20:43 +0200)
committerJim Meyering <meyering@redhat.com>
Wed, 26 Aug 2009 07:25:21 +0000 (09:25 +0200)
* tests/tail-2/assert: Avoid spurious failure due to race condition.
Rather than sleeping for 1 second and crossing fingers,
wait explicitly for backgrounded tail process to start.
Otherwise, this test would fail under heavy load.

tests/tail-2/assert

index 416f206a19a07a944623202e1e73be3c92671ac9..623c3684f268db6397cf004f9d7425fe77da506f 100755 (executable)
@@ -42,9 +42,13 @@ tail_pid=$!
 
 echo sleeping for 7 seconds...
 
-# Give the backgrounded `tail' a chance to start before removing foo.
+# Wait for the backgrounded `tail' to start before removing foo.
 # Otherwise, without --retry, tail wouldn't try to open `foo' again.
-sleep 1
+while :; do
+  env kill -0 $tail_pid && break
+  echo sleep .1
+  sleep .1
+done
 
 rm -f foo
 sleep 6