You guys had the right idea in sm/misc.c around line 57. If GPG_TTY is not set, and we
can't get a ttyname off of fd 0, then use "/dev/tty", which is a magic character-special
device that always refers to the current process's controlling terminal.
That logic (that was already in there, thanks to you guys) works great! It just needs to
be copied to the two *other* places in the code that do the same kind of thing.
To see this problem in action, make sure you do not have GPG_TTY set ("unsetenv GPG_TTY")
and run:
touch a_file
gpg -a --clearsign < a_file > out_file
You will notice that it gets confused and fails to pop up the ncurses-based screen for
entering your passphrase.
Enclosed is a patch. Thanks!!