# HG changeset patch # User Chris Manchester # Date 1531421448 25200 # Thu Jul 12 11:50:48 2018 -0700 # Node ID 8658af4e92de8b45f53ecf1d284164c46e15ca33 # Parent 46ef7ca5a86b486b826d3bc4abcdad16aa01fb28 Bug 1475058 - Send SIGINT when interrupting interactive in mach before sending SIGKILL. r=mshal MozReview-Commit-ID: 2XxLyNi1ZuS diff --git a/python/mach/mach/mixin/process.py b/python/mach/mach/mixin/process.py --- a/python/mach/mach/mixin/process.py +++ b/python/mach/mach/mixin/process.py @@ -3,16 +3,17 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # This module provides mixins to perform process execution. from __future__ import absolute_import, unicode_literals import logging import os +import signal import subprocess import sys from mozprocess.processhandler import ProcessHandlerMixin from .logging import LoggingMixin @@ -132,21 +133,29 @@ class ProcessExecutionMixin(LoggingMixin else: p = ProcessHandlerMixin(args, cwd=cwd, env=use_env, processOutputLine=[handleLine], universal_newlines=True, ignore_children=ignore_children) p.run() p.processOutput() status = None + sig = None while status is None: try: - status = p.wait() + if sig is None: + status = p.wait() + else: + status = p.kill(sig=sig) except KeyboardInterrupt: - status = p.kill() + if sig is None: + sig = signal.SIGINT + elif sig == signal.SIGINT: + # If we've already tried SIGINT, escalate. + sig = signal.SIGKILL if ensure_exit_code is False: return status if ensure_exit_code is True: ensure_exit_code = 0 if status != ensure_exit_code: