summaryrefslogtreecommitdiffstats
path: root/usr.bin/wall/wall.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/wall/wall.c')
-rw-r--r--usr.bin/wall/wall.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c
index 3bea44d..a8ac257 100644
--- a/usr.bin/wall/wall.c
+++ b/usr.bin/wall/wall.c
@@ -153,6 +153,10 @@ makemsg(fname)
(void)unlink(tmpname);
if (!nobanner) {
+ char *tty = ttyname(2);
+ if (!tty)
+ tty = "no tty";
+
if (!(whom = getlogin()))
whom = (pw = getpwuid(getuid())) ? pw->pw_name : "???";
(void)gethostname(hostname, sizeof(hostname));
@@ -172,7 +176,7 @@ makemsg(fname)
whom, hostname);
(void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf);
(void)snprintf(lbuf, sizeof(lbuf),
- " (%s) at %d:%02d %s...", ttyname(2),
+ " (%s) at %d:%02d %s...", tty,
lt->tm_hour, lt->tm_min, lt->tm_zone);
(void)fprintf(fp, "%-79.79s\r\n", lbuf);
}
OpenPOWER on IntegriCloud