[orca] fix for bug 626967 - Added a new function to wait to orca's instance kills.



commit 8e9c202e487b7a8a8e8d046f2820266a40dc7f71
Author: Alejandro Leiva <aleiva emergya es>
Date:   Mon Aug 16 16:32:31 2010 +0200

    fix for bug 626967 - Added a new function to wait to orca's instance kills.

 src/orca/orca.in |   41 +++++++++++++++++++++++++++++++++++------
 1 files changed, 35 insertions(+), 6 deletions(-)
---
diff --git a/src/orca/orca.in b/src/orca/orca.in
index d47fb96..0cddc4b 100644
--- a/src/orca/orca.in
+++ b/src/orca/orca.in
@@ -76,6 +76,19 @@ restoreXmodmap()
     fi
 }
 
+getOrcaInstances()
+{
+    USERID=`id | cut -f2 -d= | cut -f1 -d\(`
+
+    PIDS=`ps -eo pid,ruid,args | grep $USERID | \
+        egrep "orca[.]orca|OAFIID[:]GNOME_Speech|OAFIID[:]GNOME_Magnifier|festival [-][-]server"|\
+        grep -v grep | awk '{ print $1 }'`
+
+    PIDS=`echo $PIDS`
+
+    return $PIDS
+}
+
 # Cleans up any orca-related processes that might be running,
 # restricting it to those processes owned by the user. These include
 # orca itself, any gnome-speech synthesis drivers, and festival
@@ -93,18 +106,33 @@ cleanup()
         KILLARG=-15
     fi
 
-    USERID=`id | cut -f2 -d= | cut -f1 -d\(`
-    PIDS=`ps -eo pid,ruid,args | grep $USERID | \
-        egrep "orca[.]orca|OAFIID[:]GNOME_Speech|OAFIID[:]GNOME_Magnifier|festival [-][-]server"|\
-        grep -v grep | awk '{ print $1 }'`
     IFS='
     '
-    PIDS=`echo $PIDS`
-    if [ "x$PIDS" != "x" ] ; then
+
+    getOrcaInstances
+    PIDS=$?
+
+    if [ "$PIDS" != "0" ] ; then
         kill $KILLARG $PIDS > /dev/null 2>&1
     fi
 }
 
+waitForCleanup()
+{
+    getOrcaInstances
+    PIDS=$?
+
+    while [ "$PIDS" != "0"  ]; do
+        if [ "$PIDS" = "$$" ]; then
+            break
+        fi
+        sleep 0.5
+        getOrcaInstances
+        PIDS=$?
+    done
+}
+
+
 trap cleanup HUP QUIT TERM INT ABRT EXIT
 
 # Runs orca.
@@ -162,6 +190,7 @@ else
     #
     if [ `echo $ARGS | grep -c "\-\-replace"` -gt 0 ] ; then
         cleanup
+        waitForCleanup
     fi
 
     # If the user passed in a flag that results in orca only



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