Skip to content

Commit 99f98ff

Browse files
committed
Terminate pipe processes instead of sending them SIGINTs
1 parent fb9fe36 commit 99f98ff

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cmd2/cmd2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,8 +1655,8 @@ def sigint_handler(self, signum: int, frame) -> None:
16551655
:param frame
16561656
"""
16571657
try:
1658-
# Forward the sigint to the current pipe process
1659-
self.pipe_proc_reader.send_sigint()
1658+
# Terminate the current pipe process
1659+
self.pipe_proc_reader.terminate()
16601660
except AttributeError:
16611661
# Ignore since self.pipe_proc_reader was None
16621662
pass
@@ -1920,7 +1920,7 @@ def _redirect_output(self, statement: Statement) -> Tuple[bool, RedirectionSaved
19201920
# We want Popen to raise an exception if it fails to open the process. Thus we don't set shell to True.
19211921
try:
19221922
# Set options to not forward signals to the pipe process. If a Ctrl-C event occurs,
1923-
# our sigint handler will forward it to the most recent pipe process. This makes sure
1923+
# our sigint handler terminate the most recent pipe process. This makes sure
19241924
# pipe processes close in the right order (most recent first).
19251925
if sys.platform == 'win32':
19261926
creationflags = subprocess.CREATE_NEW_PROCESS_GROUP

cmd2/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ def __init__(self, proc: subprocess.Popen, stdout: Union[StdSim, BinaryIO, TextI
404404
if self._proc.stderr is not None:
405405
self._err_thread.start()
406406

407-
def send_sigint(self) -> None:
408-
"""Send a SIGINT to the process"""
407+
def terminate(self) -> None:
408+
"""Terminate the process"""
409409
import signal
410-
self._proc.send_signal(signal.SIGINT)
410+
self._proc.terminate()
411411

412412
def wait(self) -> None:
413413
"""Wait for the process to finish"""

0 commit comments

Comments
 (0)