]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: tail-2/wait: don't fail when run as root
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 2 Jul 2009 21:40:40 +0000 (23:40 +0200)
committerJim Meyering <meyering@redhat.com>
Fri, 3 Jul 2009 15:52:30 +0000 (17:52 +0200)
* tests/tail-2/wait: Ensure that the unreadable file really is not
readable before trying to run "tail -f" on it.

tests/tail-2/wait

index 7eee8b15976088421075db26e4ae7b7f1d9041eb..8f2f6107ff7dc94bde5a5f96301b6cdbb35e1309 100755 (executable)
@@ -45,17 +45,20 @@ if test -n "$state"; then
   kill $pid
 fi
 
-tail -s0.1 -f not_accessible &
-pid=$!
-sleep .5
-state=$(get_process_status_ $pid)
-
-if test -n "$state"; then
-  case $state in
-    S*) echo $0: process still active 1>&2; fail=1 ;;
-    *) ;;
-  esac
-  kill $pid
+# Check if the file is really not accessible before use it.
+if ! cat not_accessible; then
+    tail -s0.1 -f not_accessible &
+    pid=$!
+    sleep .5
+    state=$(get_process_status_ $pid)
+
+    if test -n "$state"; then
+        case $state in
+            S*) echo $0: process still active 1>&2; fail=1 ;;
+            *) ;;
+        esac
+        kill $pid
+    fi
 fi
 
 (tail -s0.1 -f here 2>tail.err) &