diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-18 22:34:57 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-11-18 22:34:57 -0500 |
commit | 43c74f7f09ef6095d21e9b5d83308e3904f636a9 (patch) | |
tree | 102ce235139e4df01cd3935661eca06b0c7b5615 /cmd2/utils.py | |
parent | 73535e1ff82b49c594fc694ef0ea898d46742750 (diff) | |
download | cmd2-git-43c74f7f09ef6095d21e9b5d83308e3904f636a9.tar.gz |
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.py | 6 |
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 |