diff options
author | brian <brian@FreeBSD.org> | 2000-12-21 01:30:47 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-12-21 01:30:47 +0000 |
commit | b92a08961bec1b7b6c9756c131e093978f2f9029 (patch) | |
tree | d1c038d90aabdf2f4ba7333b9e3524c81fd710da /usr.bin/w/w.c | |
parent | 932e6061e717d0f8dfb16dc987042a473dff9ebc (diff) | |
download | FreeBSD-src-b92a08961bec1b7b6c9756c131e093978f2f9029.zip FreeBSD-src-b92a08961bec1b7b6c9756c131e093978f2f9029.tar.gz |
If the utmp login time is greater than the tty atime, use it to calculate
the idle time instead of the atime.
This makes entries for people that have logged in but done nothing
else show up correctly.
Reviewed by: markk@knigma.org
Diffstat (limited to 'usr.bin/w/w.c')
-rw-r--r-- | usr.bin/w/w.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 0ead030..6ab256a 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -134,6 +134,7 @@ main(argc, argv) struct stat *stp; FILE *ut; u_long l; + time_t touched; int ch, i, nentries, nusers, wcmd, longidle, dropgid; char *memf, *nlistf, *p, *x; char buf[MAXHOSTNAMELEN], errbuf[256]; @@ -246,7 +247,12 @@ main(argc, argv) (void)sysctl(mib, 2, &ep->tdev, &size, NULL, 0); } #endif - if ((ep->idle = now - stp->st_atime) < 0) + touched = stp->st_atime; + if (touched < ep->utmp.ut_time) { + /* tty untouched since before login */ + touched = ep->utmp.ut_time; + } + if ((ep->idle = now - touched) < 0) ep->idle = 0; } (void)fclose(ut); |