summaryrefslogtreecommitdiff
path: root/cmd2/utils.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-11-17 15:13:46 -0500
committerGitHub <noreply@github.com>2019-11-17 15:13:46 -0500
commit73535e1ff82b49c594fc694ef0ea898d46742750 (patch)
tree66ed54cf0a73ef86c5c861c6c5122bf269fad9dc /cmd2/utils.py
parent0fc04d2091069ddabf776bd9fddf0408b81e57af (diff)
parentc474c4cb7a910f033cd53764dcf45c68c6b939d2 (diff)
downloadcmd2-git-73535e1ff82b49c594fc694ef0ea898d46742750.tar.gz
Merge pull request #810 from python-cmd2/read_input
cmd2-specific input() function
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r--cmd2/utils.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 88fbc1da..3155c64a 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -520,10 +520,15 @@ 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
+ try:
+ group_id = os.getpgid(self._proc.pid)
+ os.killpg(group_id, signal.SIGINT)
+ except ProcessLookupError:
+ return
def terminate(self) -> None:
"""Terminate the process"""