Bug 1276886 - [mozprocess] Fix hang in output readers when process is in a new process group. r=ahal
authorHenrik Skupin <mail@hskupin.info>
Thu, 02 Jun 2016 20:19:34 +0200
changeset 339429 dd6fb8e96ae4b9b2c2150e0515919ca8985b672b
parent 339428 f19d56c111d97f08611c15d42627958ee2de30ef
child 339430 fca24589e9666a482ba169a446f8f19eef66b841
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1276886
milestone49.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 1276886 - [mozprocess] Fix hang in output readers when process is in a new process group. r=ahal MozReview-Commit-ID: 9e6HNAaF0Yo In case of in-process restarts it can happen that the new process gets forked into a new process group. When that happens we loose the capability to kill the process. To prevent a hang when joining the output reader threads in wait(), we simply skip that call by passing-through the IO error.
testing/mozbase/mozprocess/mozprocess/processhandler.py
--- a/testing/mozbase/mozprocess/mozprocess/processhandler.py
+++ b/testing/mozbase/mozprocess/mozprocess/processhandler.py
@@ -145,19 +145,22 @@ class ProcessHandlerMixin(object):
                         winprocess.GetExitCodeProcess(self._handle)
                         self._cleanup()
             else:
                 def send_sig(sig):
                     if not self._ignore_children:
                         try:
                             os.killpg(self.pid, sig)
                         except BaseException as e:
+                            # Error 3 is a "no such process" failure, which is fine because the
+                            # application might already have been terminated itself. Any other
+                            # error would indicate a problem in killing the process.
                             if getattr(e, "errno", None) != 3:
-                                # Error 3 is "no such process", which is ok
-                                print >> sys.stdout, "Could not kill process, could not find pid: %s, assuming it's already dead" % self.pid
+                                print >> sys.stderr, "Could not terminate process: %s" % self.pid
+                                raise
                     else:
                         os.kill(self.pid, sig)
 
                 if sig is None and isPosix:
                     # ask the process for termination and wait a bit
                     send_sig(signal.SIGTERM)
                     limit = time.time() + self.TIMEOUT_BEFORE_SIGKILL
                     while time.time() <= limit: