Skip to content

Commit 9a53e36

Browse files
committed
Fixed ProcessLookupError
1 parent d0ba1d5 commit 9a53e36

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd2/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,11 @@ def send_sigint(self) -> None:
524524
else:
525525
# Since cmd2 uses shell=True in its Popen calls, we need to send the SIGINT to
526526
# the whole process group to make sure it propagates further than the shell
527-
os.killpg(os.getpgid(self._proc.pid), signal.SIGINT)
527+
try:
528+
group_id = os.getpgid(self._proc.pid)
529+
os.killpg(group_id, signal.SIGINT)
530+
except ProcessLookupError:
531+
return
528532

529533
def terminate(self) -> None:
530534
"""Terminate the process"""

0 commit comments

Comments
 (0)