When GPG_TTY is set to an invalid TTY, GPG will hang upon any invocation that requires the use of private keys. I suspect it is doing so as it does not know which TTY to send pinentry to.
Reproduction steps:
- Set GPG_TTY to an invalid value (such as "not a tty") in the shell init script (such as .zshrc)
- Invoke any GPG command that requires the use of private keys (such as gpg -vvv -K)
- GPG will start up and hang indefinitely until Control-C is issued
More reproduction steps:
- Set GPG_TTY to $(tty)
- Install a ZSH theme such as Powerlevel10k that late-inits tty, which means the above will be set to "not a tty"
- Invoke any GPG command that requires the use of private keys (such as gpg -vvv -K)
- GPG will start up and hang indefinitely until Control-C is issued
- Workaround: set GPG_TTY to $TTY, which is a ZSH variable for the TTY and is compatible with late-init
Expected behavior: GPG should detect that the given TTY is invalid, let the user know, and exit cleanly.