summaryrefslogtreecommitdiffstats
path: root/usr.bin/wall
diff options
context:
space:
mode:
authorn_hibma <n_hibma@FreeBSD.org>2000-10-02 17:31:57 +0000
committern_hibma <n_hibma@FreeBSD.org>2000-10-02 17:31:57 +0000
commitd4edaae88f77cb78f7e0d294fef285db9617bd9c (patch)
tree5bb228cfa97a7ac879e6cecd2467a489c0333459 /usr.bin/wall
parent7e9332da7901c1a05aa79c878c442de09b13b7ea (diff)
downloadFreeBSD-src-d4edaae88f77cb78f7e0d294fef285db9617bd9c.zip
FreeBSD-src-d4edaae88f77cb78f7e0d294fef285db9617bd9c.tar.gz
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.
Diffstat (limited to 'usr.bin/wall')
-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