diff --git a/kitty/remote_control.py b/kitty/remote_control.py index 81970bb81..9150ada06 100644 --- a/kitty/remote_control.py +++ b/kitty/remote_control.py @@ -408,7 +408,8 @@ def get_password(opts: RCOptions) -> str: except OSError: pass else: - os.dup2(tty_fd, sys.stdin.fileno()) + with open(tty_fd, closefd=True): + os.dup2(tty_fd, sys.stdin.fileno()) else: try: with open(resolve_custom_file(opts.password_file)) as f: