Bug 911262 - Use os.kill instead of ctypes in automation.py. r=ted
authorMihnea Dobrescu-Balaur <mihneadb@gmail.com>
Fri, 30 Aug 2013 11:27:23 -0700
changeset 145129 fbef2705edfcb9b487e702015d10acd4500d08f4
parent 145128 a4252161972b4c126fb842baa3f8f7ef26ea6f64
child 145130 6bd785bca4ff7a4cbbd34616d6e2b0f3dcbbdb0a
push id25194
push userryanvm@gmail.com
push dateSat, 31 Aug 2013 00:37:36 +0000
treeherdermozilla-central@1ac8270f3f64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs911262
milestone26.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 911262 - Use os.kill instead of ctypes in automation.py. r=ted
build/automation.py.in
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -532,16 +532,19 @@ class Automation(object):
           self.log.info("INFO | automation.py | ASan running in default memory configuration")
       except OSError,err:
         self.log.info("Failed determine available memory, disabling ASan low-memory configuration: %s", err.strerror)
       except:
         self.log.info("Failed determine available memory, disabling ASan low-memory configuration")
 
     return env
 
+  def killPid(self, pid):
+    os.kill(pid, getattr(signal, "SIGKILL", signal.SIGTERM))
+
   if IS_WIN32:
     PeekNamedPipe = ctypes.windll.kernel32.PeekNamedPipe
     GetLastError = ctypes.windll.kernel32.GetLastError
 
     def readWithTimeout(self, f, timeout):
       """
       Try to read a line of output from the file object |f|. |f| must be a
       pipe, like the |stdout| member of a subprocess.Popen object created
@@ -582,24 +585,16 @@ class Automation(object):
       pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid)
       if not pHandle:
         return False
       pExitCode = ctypes.wintypes.DWORD()
       ctypes.windll.kernel32.GetExitCodeProcess(pHandle, ctypes.byref(pExitCode))
       ctypes.windll.kernel32.CloseHandle(pHandle)
       return pExitCode.value == STILL_ACTIVE
 
-    def killPid(self, pid):
-      PROCESS_TERMINATE = 0x0001
-      pHandle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
-      if not pHandle:
-        return
-      ctypes.windll.kernel32.TerminateProcess(pHandle, 1)
-      ctypes.windll.kernel32.CloseHandle(pHandle)
-
   else:
 
     def readWithTimeout(self, f, timeout):
       """Try to read a line of output from the file object |f|. If no output
       is received within |timeout| seconds, return a blank line.
       Returns a tuple (line, did_timeout), where |did_timeout| is True
       if the read timed out, and False otherwise."""
       (r, w, e) = select.select([f], [], [], timeout)
@@ -619,19 +614,16 @@ class Automation(object):
         return wpid == 0
       except OSError, err:
         # Catch the errors we might expect from os.kill/os.waitpid, 
         # and re-raise any others
         if err.errno == errno.ESRCH or err.errno == errno.ECHILD:
           return False
         raise
 
-    def killPid(self, pid):
-      os.kill(pid, signal.SIGKILL)
-
   def dumpScreen(self, utilityPath):
     if self.haveDumpedScreen:
       self.log.info("Not taking screenshot here: see the one that was previously logged")
       return
 
     self.haveDumpedScreen = True;
 
     # Need to figure out what tool and whether it write to a file or stdout