Bug 1145364 - Use more portable ps command line for orphan cleanup; r=kmoir
authorGeoff Brown <gbrown@mozilla.com>
Fri, 20 Mar 2015 13:50:14 -0600
changeset 234818 bf9e8b4096cf72dc9babb8bf4043df52882dfd2b
parent 234817 5444d8c669fc5d1ba1dea10dd8b53c1bf40df130
child 234819 9b47ec7ffe71b8da76d3e3bd0915ce82513bfe78
push id28454
push userphilringnalda@gmail.com
push dateSat, 21 Mar 2015 19:32:28 +0000
treeherdermozilla-central@f949be6cd23e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmoir
bugs1145364
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1145364 - Use more portable ps command line for orphan cleanup; r=kmoir
layout/tools/reftest/runreftest.py
testing/mochitest/runtests.py
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -284,32 +284,32 @@ class RefTest(object):
     return browserEnv
 
   def killNamedOrphans(self, pname):
     """ Kill orphan processes matching the given command name """
     log.info("Checking for orphan %s processes..." % pname)
     def _psInfo(line):
       if pname in line:
         log.info(line)
-    process = mozprocess.ProcessHandler(['ps', '-f', '--no-headers'],
+    process = mozprocess.ProcessHandler(['ps', '-f'],
                                         processOutputLine=_psInfo)
     process.run()
     process.wait()
 
     def _psKill(line):
       parts = line.split()
-      pid = int(parts[0])
-      if len(parts) == 3 and parts[2] == pname and parts[1] == '1':
-        log.info("killing %s orphan with pid %d" % (pname, pid))
-        try:
-          os.kill(pid, getattr(signal, "SIGKILL", signal.SIGTERM))
-        except Exception as e:
-          log.info("Failed to kill process %d: %s" % (pid, str(e)))
-
-    process = mozprocess.ProcessHandler(['ps', '-o', 'pid,ppid,comm', '--no-headers'],
+      if len(parts) == 3 and parts[0].isdigit():
+        pid = int(parts[0])
+        if parts[2] == pname and parts[1] == '1':
+          log.info("killing %s orphan with pid %d" % (pname, pid))
+          try:
+            os.kill(pid, getattr(signal, "SIGKILL", signal.SIGTERM))
+          except Exception as e:
+            log.info("Failed to kill process %d: %s" % (pid, str(e)))
+    process = mozprocess.ProcessHandler(['ps', '-o', 'pid,ppid,comm'],
                                         processOutputLine=_psKill)
     process.run()
     process.wait()
 
   def cleanup(self, profileDir):
     if profileDir:
       shutil.rmtree(profileDir, True)
 
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -2028,28 +2028,29 @@ class Mochitest(MochitestUtilsMixin):
         return result
 
     def killNamedOrphans(self, pname):
         """ Kill orphan processes matching the given command name """
         self.log.info("Checking for orphan %s processes..." % pname)
         def _psInfo(line):
             if pname in line:
                 self.log.info(line)
-        process = mozprocess.ProcessHandler(['ps', '-f', '--no-headers'],
+        process = mozprocess.ProcessHandler(['ps', '-f'],
                                             processOutputLine=_psInfo)
         process.run()
         process.wait()
 
         def _psKill(line):
             parts = line.split()
-            pid = int(parts[0])
-            if len(parts) == 3 and parts[2] == pname and parts[1] == '1':
-                self.log.info("killing %s orphan with pid %d" % (pname, pid))
-                killPid(pid, self.log)
-        process = mozprocess.ProcessHandler(['ps', '-o', 'pid,ppid,comm', '--no-headers'],
+            if len(parts) == 3 and parts[0].isdigit():
+                pid = int(parts[0])
+                if parts[2] == pname and parts[1] == '1':
+                    self.log.info("killing %s orphan with pid %d" % (pname, pid))
+                    killPid(pid, self.log)
+        process = mozprocess.ProcessHandler(['ps', '-o', 'pid,ppid,comm'],
                                             processOutputLine=_psKill)
         process.run()
         process.wait()
 
     def runTests(self, options, onLaunch=None):
         """ Prepare, configure, run tests and cleanup """
 
         self.setTestRoot(options)