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.
--- 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: