[orca] Kill more, kill more often (Ensure we eliminate replaced Orca processes)



commit d1e7d3855a82677344064686f778e9e1c168db7d
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat May 12 19:55:42 2012 -0400

    Kill more, kill more often (Ensure we eliminate replaced Orca processes)

 src/orca/orca.py |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 0a47d9c..2cb1f00 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -1324,8 +1324,7 @@ def otherOrcas():
     orcas = [int(p) for p in pids.split()]
 
     pid = os.getpid()
-    ppid = os.getppid()
-    return [p for p in orcas if p not in [pid, ppid]]
+    return [p for p in orcas if p != pid]
 
 def multipleOrcas():
     """Returns True if multiple instances of Orca are running which are
@@ -1336,7 +1335,21 @@ def multipleOrcas():
 def cleanup(sigval):
     """Tries to clean up any other running Orca instances owned by this user."""
 
-    map(lambda x: os.kill(x, sigval), otherOrcas())
+    orcasToKill = otherOrcas()
+    debug.println(
+        debug.LEVEL_INFO, "INFO: Cleaning up these PIDs: %s" % orcasToKill)
+
+    def onTimeout(signum, frame):
+        orcasToKill = otherOrcas()
+        debug.println(
+            debug.LEVEL_INFO, "INFO: Timeout cleaning up: %s" % orcasToKill)
+        map(lambda x: os.kill(x, signal.SIGKILL), orcasToKill)
+
+    map(lambda x: os.kill(x, sigval), orcasToKill)
+    signal.signal(signal.SIGALRM, onTimeout)
+    signal.alarm(2)
+    while otherOrcas():
+        time.sleep(0.5)
 
 def cleanupGarbage():
     """Cleans up garbage on the heap."""



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