mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
ctrl-c should prompt for an exit
This commit is contained in:
parent
cd660a035f
commit
b3dac13184
@ -11,6 +11,7 @@ import signal
|
|||||||
import typing
|
import typing
|
||||||
|
|
||||||
from mitmproxy.tools import cmdline
|
from mitmproxy.tools import cmdline
|
||||||
|
from mitmproxy.tools.console.master import ConsoleMaster
|
||||||
from mitmproxy import exceptions, master
|
from mitmproxy import exceptions, master
|
||||||
from mitmproxy import options
|
from mitmproxy import options
|
||||||
from mitmproxy import optmanager
|
from mitmproxy import optmanager
|
||||||
@ -114,6 +115,9 @@ def run(
|
|||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
for signame in ('SIGINT', 'SIGTERM'):
|
for signame in ('SIGINT', 'SIGTERM'):
|
||||||
try:
|
try:
|
||||||
|
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)
|
loop.add_signal_handler(getattr(signal, signame), master.shutdown)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
# Not supported on Windows
|
# Not supported on Windows
|
||||||
|
Loading…
Reference in New Issue
Block a user