diff options
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index 88fbc1da..e3d54ffe 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -520,10 +520,11 @@ class ProcReader(object): """Send a SIGINT to the process similar to if <Ctrl>+C were pressed.""" import signal if sys.platform.startswith('win'): - signal_to_send = signal.CTRL_C_EVENT + self._proc.send_signal(signal.CTRL_C_EVENT) else: - signal_to_send = signal.SIGINT - self._proc.send_signal(signal_to_send) + # 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 + os.killpg(os.getpgid(self._proc.pid), signal.SIGINT) def terminate(self) -> None: """Terminate the process""" |