diff options
Diffstat (limited to 'usr.bin/finger/util.c')
-rw-r--r-- | usr.bin/finger/util.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 229d58a..3ac5a06 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -314,10 +314,23 @@ find_idle_and_ttywrite(WHERE *w) { struct stat sb; time_t touched; + int error; (void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty); - if (stat(tbuf, &sb) < 0) { + + error = stat(tbuf, &sb); + if (error < 0 && errno == ENOENT) { + /* + * The terminal listed is not actually a terminal (i.e., + * ":0"). This is a failure, so we'll skip printing + * out the idle time, which is non-ideal but better + * than a bogus warning and idle time. + */ + w->idletime = -1; + return; + } else if (error < 0) { warn("%s", tbuf); + w->idletime = -1; return; } touched = sb.st_atime; |