Ignore sigint while draining the tty

This commit is contained in:
Kovid Goyal 2022-07-20 19:40:23 +05:30
parent 7215c6d6be
commit ef2a12fbdf
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -605,13 +605,14 @@ def drain_potential_tty_garbage(p: 'subprocess.Popen[bytes]', data_request: str)
give_up_at = time.monotonic() + 2 give_up_at = time.monotonic() + 2
tty_fd = tty.fileno() tty_fd = tty.fileno()
while time.monotonic() < give_up_at and canary not in data: while time.monotonic() < give_up_at and canary not in data:
rd, wr, err = select([tty_fd], [], [tty_fd], max(0, give_up_at - time.monotonic())) with suppress(KeyboardInterrupt):
if err or not rd: rd, wr, err = select([tty_fd], [], [tty_fd], max(0, give_up_at - time.monotonic()))
break if err or not rd:
q = os.read(tty_fd, io.DEFAULT_BUFFER_SIZE) break
if not q: q = os.read(tty_fd, io.DEFAULT_BUFFER_SIZE)
break if not q:
data += q break
data += q
def change_colors(color_scheme: str) -> bool: def change_colors(color_scheme: str) -> bool: