--- common/asshelp.c +++ common/asshelp.c @@ -90,6 +90,8 @@ dft_ttyname = getenv ("GPG_TTY"); if ((!dft_ttyname || !*dft_ttyname) && ttyname (0)) dft_ttyname = ttyname (0); + if (!dft_ttyname) + dft_ttyname = "/dev/tty"; } if (opt_ttyname || dft_ttyname) { --- common/simple-pwquery.c +++ common/simple-pwquery.c @@ -217,6 +217,8 @@ #ifndef HAVE_W32_SYSTEM if ((!dft_ttyname || !*dft_ttyname) && ttyname (0)) dft_ttyname = ttyname (0); + if (!dft_ttyname) + dft_ttyname = "/dev/tty"; #endif if (dft_ttyname && *dft_ttyname) {