From: Jim Meyering Date: Tue, 25 Aug 2009 18:43:13 +0000 (+0200) Subject: tests: tail-2/assert: avoid risk of race condition X-Git-Tag: v7.6~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be853120;p=thirdparty%2Fcoreutils.git tests: tail-2/assert: avoid risk of race condition * 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. --- diff --git a/tests/tail-2/assert b/tests/tail-2/assert index 416f206a19..623c3684f2 100755 --- a/tests/tail-2/assert +++ b/tests/tail-2/assert @@ -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