summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-11-19 01:19:45 -0500
committerGitHub <noreply@github.com>2019-11-19 01:19:45 -0500
commit8c00d342ee3967e09cce436d76208238307d1cd4 (patch)
treeba7a6658f7f0520aeab180b5809a01d00bdc5429 /cmd2/utils.py
parent73535e1ff82b49c594fc694ef0ea898d46742750 (diff)
parent1a77e7ba6bc1bd84b70589f966c726f616ce6a96 (diff)
downloadcmd2-git-8c00d342ee3967e09cce436d76208238307d1cd4.tar.gz
Merge pull request #811 from python-cmd2/win_fix
Fixed bug where pipe processes were not being stopped by Ctrl-C on Windows
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 3155c64a..a1a0d377 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -517,10 +517,12 @@ class ProcReader(object):
self._err_thread.start()
def send_sigint(self) -> None:
- """Send a SIGINT to the process similar to if <Ctrl>+C were pressed."""
+ """Send a SIGINT to the process similar to if <Ctrl>+C were pressed"""
import signal
if sys.platform.startswith('win'):
- self._proc.send_signal(signal.CTRL_C_EVENT)
+ # cmd2 started the Windows process in a new process group. Therefore
+ # a CTRL_C_EVENT can't be sent to it. Send a CTRL_BREAK_EVENT instead.
+ self._proc.send_signal(signal.CTRL_BREAK_EVENT)
else:
# Since cmd2 uses shell=True in its Popen calls, we need to send the SIGINT to
# the whole process group to make sure it propagates further than the shell