diff --git a/configure.in b/configure.in index 4740fb9..2285b58 100644 --- a/configure.in +++ b/configure.in @@ -2322,6 +2322,8 @@ AC_CHECK_FUNCS(getpt) # than to expect to find it in ncurses. AC_CHECK_LIB(ncurses, tparm) +AC_CHECK_FUNCS(ttyname) + # Do we have res_init, for detecting changes in /etc/resolv.conf? resolv=no diff --git a/src/term.c b/src/term.c index 4e63568..fe1edd0 100644 --- a/src/term.c +++ b/src/term.c @@ -3351,7 +3351,16 @@ init_tty (char *name, char *terminal_type, int must_succeed) file = fdopen (fd, "w+"); tty->name = xstrdup (name); - terminal->name = xstrdup (name); + +#if HAVE_TTYNAME + if (ctty) + { + char *ctty_name = ttyname (0); + terminal->name = xstrdup (ctty_name ? ctty_name : name); + } + else +#endif + terminal->name = xstrdup (name); tty->input = file; tty->output = file; }