diff options
author | Sami Kerola | 2013-08-28 19:53:22 +0200 |
---|---|---|
committer | Sami Kerola | 2013-08-29 19:14:10 +0200 |
commit | 31d28e09510f0a1fe8c11617f33fb4c445d041ac (patch) | |
tree | 063fd03524f039d126cea31c59edcbb4e4881ada /login-utils/last.c | |
parent | last: trim trailing white spaces (diff) | |
download | kernel-qcow2-util-linux-31d28e09510f0a1fe8c11617f33fb4c445d041ac.tar.gz kernel-qcow2-util-linux-31d28e09510f0a1fe8c11617f33fb4c445d041ac.tar.xz kernel-qcow2-util-linux-31d28e09510f0a1fe8c11617f33fb4c445d041ac.zip |
last: tell verbally system is still running
Use of uptime time stamp as previous boot login time makes the output not
constant, which is rather difficult to test. Verbal message 'system is
still running' makes testing easy, and noticing which boot is still
running clear to a person.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index 73a4b4791..419162e29 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -370,7 +370,7 @@ static void trim_trailing_spaces(char *s) */ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int what) { - time_t secs, tmp; + time_t secs, tmp, epoch; char logintime[LAST_TIMESTAMP_LEN]; char logouttime[LAST_TIMESTAMP_LEN]; char length[LAST_TIMESTAMP_LEN]; @@ -421,7 +421,16 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh mins = (secs / 60) % 60; hours = (secs / 3600) % 24; days = secs / 86400; - if (days) + + epoch = time(NULL); + if (t == epoch) { + if (ctl->fulltime) + sprintf(logouttime, " still running"); + else { + sprintf(logouttime, " still"); + sprintf(length, "running"); + } + } else if (days) sprintf(length, "(%d+%02d:%02d)", days, hours, mins); else sprintf(length, " (%02d:%02d)", hours, mins); |