diff --git a/mitmproxy/tools/_main.py b/mitmproxy/tools/_main.py index a00a3e989..11a873278 100644 --- a/mitmproxy/tools/_main.py +++ b/mitmproxy/tools/_main.py @@ -11,6 +11,7 @@ import signal import typing from mitmproxy.tools import cmdline +from mitmproxy.tools.console.master import ConsoleMaster from mitmproxy import exceptions, master from mitmproxy import options from mitmproxy import optmanager @@ -114,7 +115,10 @@ def run( loop = asyncio.get_event_loop() for signame in ('SIGINT', 'SIGTERM'): try: - loop.add_signal_handler(getattr(signal, signame), master.shutdown) + if isinstance(master, ConsoleMaster): + loop.add_signal_handler(getattr(signal, signame), master.prompt_for_exit) + else: + loop.add_signal_handler(getattr(signal, signame), master.shutdown) except NotImplementedError: # Not supported on Windows pass