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.
This commit is contained in:
Nick Hibma 2000-10-02 17:31:57 +00:00
parent 8c964b9bca
commit 80af0816cd
1 changed files with 5 additions and 1 deletions

View File

@ -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);
}