git-cl: Make Ctrl+C work again.

Bug: 961724
Change-Id: I4fc8f86c02fb53310c5967284594ba1fbbbcbafc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1826054
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
changes/54/1826054/7
Edward Lemur 6 years ago committed by Commit Bot
parent f0faf48ddb
commit 9a5bb612e6

@ -90,11 +90,8 @@ class CommandData(object):
# Before a SIGINT is seen, wait(p) will simply call p.wait() and
# return the result. Once a SIGINT has been seen (in the main process
# or a subprocess, including the one the current call is waiting for),
# wait(p) will call p.terminate() and raise ProcessWasInterrupted.
# wait(p) will call p.terminate().
class SigintHandler(object):
class ProcessWasInterrupted(Exception):
pass
sigint_returncodes = {-signal.SIGINT, # Unix
-1073741510, # Windows
}
@ -102,7 +99,7 @@ class SigintHandler(object):
self.__lock = threading.Lock()
self.__processes = set()
self.__got_sigint = False
signal.signal(signal.SIGINT, lambda signal_num, frame: self.interrupt())
self.__previous_signal = signal.signal(signal.SIGINT, self.interrupt)
def __on_sigint(self):
self.__got_sigint = True
@ -112,9 +109,10 @@ class SigintHandler(object):
except OSError:
pass
def interrupt(self):
def interrupt(self, signal_num, frame):
with self.__lock:
self.__on_sigint()
self.__previous_signal(signal_num, frame)
def got_sigint(self):
with self.__lock:
@ -131,8 +129,6 @@ class SigintHandler(object):
self.__processes.discard(p)
if code in self.sigint_returncodes:
self.__on_sigint()
if self.__got_sigint:
raise self.ProcessWasInterrupted
return stdout, stderr
sigint_handler = SigintHandler()

Loading…
Cancel
Save