From 80af0816cd85fbae8cad6867e0f9e00df09e30c8 Mon Sep 17 00:00:00 2001 From: Nick Hibma Date: Mon, 2 Oct 2000 17:31:57 +0000 Subject: [PATCH] Instead of printing '(null)' if there is no tty, print 'no tty'. In the case where the program is executed by a daemon running in the background the terminal might not have a tty. The '(null)' is confusing. --- usr.bin/wall/wall.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/wall/wall.c b/usr.bin/wall/wall.c index 3bea44d5772..a8ac25705a5 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); } -- 2.45.2