[tabled patch 2/2] test/start-daemon: Ignore stale .pid files.

Pete Zaitcev <[email protected]> Wed, 22 Sep 2010 17:15:54 -0600
Newsgroups org.kernel.vger.hail-devel
Message-ID <[email protected]>
The effect of this is to proceed with "make check" if
 - stale file is present, and
 - no process uses the PID recorded therein.
So, the worst that can happen is a revert to old behavior if an unrelated
process reuses the PID. Should make no difference for RPM builds at all.

Signed-off-by: Jim Meyering <[email protected]>
Signed-off-by: Pete Zaitcev <[email protected]>

---
 test/start-daemon |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

You know, if we decide that we want to permit "make check" on unclean tree
(which is where this patch aims), we might want to rm -r test/data too.
Otherwise code 1111 lock conflicts are inevitable and check is likely
to fail anyway.

diff --git a/test/start-daemon b/test/start-daemon
index da653d6..6985468 100755
--- a/test/start-daemon
+++ b/test/start-daemon
@@ -1,10 +1,14 @@
 #!/bin/sh
 
-for d in cld chunkd tabled; do
+for d in cld chunkd tabled
+do
 	if [ -f $d.pid ]
 	then
-		echo "$d.pid file found.  daemon still running?"
-		exit 1
+		if kill -0 `cat $d.pid` 2> /dev/null
+		then
+			echo "$d.pid file found.  daemon still running?" >&2
+			exit 1
+		fi
 	fi
 done