mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 10:12:17 +02:00
ssh kitten: Better handling of exit on keyboard interrupt
This commit is contained in:
@@ -717,16 +717,13 @@ def run_ssh(ssh_args: List[str], server_args: List[str], found_extra_args: Tuple
|
|||||||
else:
|
else:
|
||||||
rq = '' if need_to_request_data else 'id={REQUEST_ID}:pwfile={PASSWORD_FILENAME}:pw={DATA_PASSWORD}'.format(**replacements)
|
rq = '' if need_to_request_data else 'id={REQUEST_ID}:pwfile={PASSWORD_FILENAME}:pw={DATA_PASSWORD}'.format(**replacements)
|
||||||
with drain_potential_tty_garbage(p, rq):
|
with drain_potential_tty_garbage(p, rq):
|
||||||
try:
|
raise SystemExit(p.wait())
|
||||||
raise SystemExit(p.wait())
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
raise SystemExit(1)
|
|
||||||
finally:
|
finally:
|
||||||
if colors_changed:
|
if colors_changed:
|
||||||
print(end=restore_colors(), flush=True)
|
print(end=restore_colors(), flush=True)
|
||||||
|
|
||||||
|
|
||||||
def main(args: List[str]) -> NoReturn:
|
def main(args: List[str]) -> None:
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
if args and args[0] == 'use-python':
|
if args and args[0] == 'use-python':
|
||||||
args = args[1:] # backwards compat from when we had a python implementation
|
args = args[1:] # backwards compat from when we had a python implementation
|
||||||
@@ -740,7 +737,11 @@ def main(args: List[str]) -> NoReturn:
|
|||||||
raise SystemExit('The SSH kitten is meant for interactive use via SSH only')
|
raise SystemExit('The SSH kitten is meant for interactive use via SSH only')
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
raise SystemExit('The SSH kitten is meant for interactive use only, STDIN must be a terminal')
|
raise SystemExit('The SSH kitten is meant for interactive use only, STDIN must be a terminal')
|
||||||
run_ssh(ssh_args, server_args, found_extra_args)
|
try:
|
||||||
|
run_ssh(ssh_args, server_args, found_extra_args)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
sys.excepthook = lambda *a: None
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user