[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tail: flush initial output before possibly blocking
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] tail: flush initial output before possibly blocking |
Date: |
Sun, 6 Sep 2009 10:50:20 +0100 |
User-agent: |
Thunderbird 2.0.0.6 (X11/20071008) |
Jim Meyering wrote:
> I noticed that tail -f "didn't work" when run via ssh.
> I.e., it printed nothing, when I expected it to print the
> last 10 lines.
well spotted.
I was wondering about the loop in the test though.
Can the `kill -0` ever fail. Even if that's not redundant
I'm not sure the file is guaranteed to be written at this stage?
How about:
diff --git a/tests/tail-2/flush-initial b/tests/tail-2/flush-initial
index 2deff84..378440c 100755
--- a/tests/tail-2/flush-initial
+++ b/tests/tail-2/flush-initial
@@ -28,10 +28,11 @@ 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
- sleep .1
+# wait for a second for the file to be flushed
+count=0
+until test -s out -o $count = 10; do
+ count=$((count+1))
+ sleep .1
done
test -s out || fail=1
cheers,
Pádraig.