Bug 1705385 - [mozprocess] Remove custom process wait code on posix, r=ahal draft
authorJames Graham <james@hoppipolla.co.uk>
Mon, 19 Apr 2021 21:12:00 +0000
changeset 3668285 87ab9f0a7ce9893429074cbb1c8e4e6c9e60398e
parent 3662984 09e277c5edc3a2c315e334d7bb1ddab0a5d26e90
child 3668286 d234160b358d40c723578a3ae5d996e3d7493ec1
push id683208
push userreviewbot
push dateMon, 19 Apr 2021 21:12:39 +0000
treeherdertry@e595080f8534 [default view] [failures only]
reviewersahal
bugs1705385
milestone89.0a1
Bug 1705385 - [mozprocess] Remove custom process wait code on posix, r=ahal This is not obviously doing more than the stdlib code does these days, and also doesn't support timeouts, so we're perhaps better just always defering to the stdlib. Differential Diff: PHID-DIFF-66gqmbz327wy3zs6pekr
testing/mozbase/mozprocess/mozprocess/processhandler.py
--- a/testing/mozbase/mozprocess/mozprocess/processhandler.py
+++ b/testing/mozbase/mozprocess/mozprocess/processhandler.py
@@ -801,78 +801,34 @@ falling back to not using job objects fo
                     self._thread = None
 
                 if self._handle and self._handle != winprocess.INVALID_HANDLE_VALUE:
                     self._handle.Close()
                     self._handle = None
                 else:
                     self._handle = None
 
-        elif isPosix:
+        else:
 
             def _custom_wait(self, timeout=None):
                 """Haven't found any reason to differentiate between these platforms
                 so they all use the same wait callback.  If it is necessary to
                 craft different styles of wait, then a new _custom_wait method
                 could be easily implemented.
                 """
-
-                if not self._ignore_children:
-                    try:
-                        # os.waitpid return value:
-                        # > [...] a tuple containing its pid and exit status
-                        # > indication: a 16-bit number, whose low byte is the
-                        # > signal number that killed the process, and whose
-                        # > high byte is the exit status (if the signal number
-                        # > is zero)
-                        # - http://docs.python.org/2/library/os.html#os.wait
-                        status = os.waitpid(self.pid, 0)[1]
-
-                        # For consistency, format status the same as subprocess'
-                        # returncode attribute
-                        if status > 255:
-                            return status >> 8
-                        return -status
-                    except OSError as e:
-                        if getattr(e, "errno", None) != 10:
-                            # Error 10 is "no child process", which could indicate normal
-                            # close
-                            print(
-                                "Encountered error waiting for pid to close: %s" % e,
-                                file=sys.stderr,
-                            )
-                            raise
-
-                        return self.returncode
-
-                else:
-                    # For non-group wait, call base class
+                # For non-group wait, call base class
+                try:
                     if six.PY2:
                         subprocess.Popen.wait(self)
                     else:
                         # timeout was introduced in Python 3.3
                         subprocess.Popen.wait(self, timeout=timeout)
-                    return self.returncode
-
-            def _cleanup(self):
-                pass
-
-        else:
-            # An unrecognized platform, we will call the base class for everything
-            print(
-                "Unrecognized platform, process groups may not " "be managed properly",
-                file=sys.stderr,
-            )
-
-            def _custom_wait(self, timeout=None):
-                if six.PY2:
-                    self.returncode = subprocess.Popen.wait(self)
-                else:
-                    # timeout was introduced in Python 3.3
-                    self.returncode = subprocess.Popen.wait(self, timeout=timeout)
+                except subprocess.TimeoutExpired:
+                    # We want to return None in this case
+                    pass
                 return self.returncode
 
             def _cleanup(self):
                 pass
 
     def __init__(
         self,
         cmd,