bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: tail-2/assert: avoid risk of race condition


From: Jim Meyering
Subject: [PATCH] tests: tail-2/assert: avoid risk of race condition
Date: Tue, 25 Aug 2009 23:28:49 +0200

I noticed that this test would occasionally fail under
heavy load (make -j9 check), so will fix it like this:

>From e9bd6841a318b91bdc43b204b0368e0373c4fd9a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 25 Aug 2009 20:43:13 +0200
Subject: [PATCH] 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.
---
 tests/tail-2/assert |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/tail-2/assert b/tests/tail-2/assert
index 416f206..623c368 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
--
1.6.4.1.331.gda1d56




reply via email to

[Prev in Thread] Current Thread [Next in Thread]