Thanks for the bug report. The situation you describe seems to be a platform that does not conform to POSIX, since POSIX doesn't allow for isatty to succeed but ttyname to fail. So I expect you'll run into problems other than with the tty program, as other software will make the same assumptions that tty is making. That being said, tty could do a better job about the situation. I installed the attached somewhat-more-ambitious patch, so that tty will do more-extensive checking of the results of isatty and/or ttyname (and so that it never needs to call both functions and worry about whether their results are consistent :-). Please give it a try on your platform.