Bug 1276886 - [mozprocess] Fix hang in output readers when process is in a new process group. r?ahal draft
authorHenrik Skupin <mail@hskupin.info>
Thu, 02 Jun 2016 20:19:34 +0200
changeset 374518 d5e864f4d913e9f1a3fda799087ab91805c6bff0
parent 373997 8cac3360b8c7438b635d98d6e0ff77437453af46
child 522660 d48272db1600a3bb4afa4929a0330f1bb4a4385c
push id20051
push userbmo:hskupin@gmail.com
push dateThu, 02 Jun 2016 18:28:35 +0000
reviewersahal
bugs1276886
milestone49.0a1
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
@@ -136,19 +136,22 @@ class ProcessHandlerMixin(object):
                     if err is not None:
                         raise OSError(err)
             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: