From 5dc1cee3132cd0cfbf27e68471b71d6e7dbabbab Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Thu, 24 Jul 2008 18:39:52 +0000
Subject: [PATCH] fix: problem with restart when previous Datamover deletes
 datamover.pid file of its successor

SVN: 7480
---
 datamover/dist/datamover.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/datamover/dist/datamover.sh b/datamover/dist/datamover.sh
index b799188ba23..19a121aa9a0 100755
--- a/datamover/dist/datamover.sh
+++ b/datamover/dist/datamover.sh
@@ -217,7 +217,16 @@ case "$command" in
       isPIDRunning $PID
       if [ $? -eq 0 ]; then
         kill $PID
-        if [ $? -eq 0 ]; then
+        n=0
+        while [ $n -lt $MAX_LOOPS ]; do
+          isPIDRunning $PID
+          if [ $? -ne 0 ]; then
+            break
+          fi
+          n=$(($n+1))
+        done
+        isPIDRunning $PID
+        if [ $? -ne 0 ]; then
           echo "(pid $PID)"
           # Shouldn't be necessary as Datamover deletes the file itself, but just to be sure
           test -f $PIDFILE && rm $PIDFILE 2> /dev/null
-- 
GitLab