Display elapsed time (-o etime) using [[dd-]hh:]mm:ss, which according to
Solaris man page is the POSIX way. Reviewed by: jmallett
This commit is contained in:
parent
e869e50704
commit
eaed5652bf
@ -36,6 +36,7 @@
|
||||
static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
@ -84,7 +84,7 @@ static VAR var[] = {
|
||||
{"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d",
|
||||
0},
|
||||
{"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 9, 0, CHAR, NULL, 0},
|
||||
{"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0},
|
||||
{"f", "F", NULL, 0, kvar, NULL, 7, KOFF(ki_flag), INT, "x", 0},
|
||||
{"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
{"ignored", "", "sigignore", 0, NULL, NULL, 0, 0, CHAR, NULL, 0},
|
||||
|
@ -36,6 +36,7 @@
|
||||
static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
@ -539,14 +540,30 @@ void
|
||||
elapsed(KINFO *k, VARENT *ve)
|
||||
{
|
||||
VAR *v;
|
||||
time_t secs;
|
||||
time_t days, hours, mins, secs;
|
||||
char obuff[128];
|
||||
|
||||
v = ve->var;
|
||||
|
||||
secs = now - k->ki_p->ki_start.tv_sec;
|
||||
(void)snprintf(obuff, sizeof(obuff), "%3ld:%02ld", (long)secs/60,
|
||||
(long)secs%60);
|
||||
days = secs/(24*60*60);
|
||||
secs %= (24*60*60);
|
||||
hours = secs/(60*60);
|
||||
secs %= (60*60);
|
||||
mins = secs/60;
|
||||
secs %= 60;
|
||||
if (days != 0) {
|
||||
(void)snprintf(obuff, sizeof(obuff), "%3ld-%02ld:%02ld:%02ld",
|
||||
(long)days, (long)hours, (long)mins, (long)secs);
|
||||
}
|
||||
else if (hours != 0) {
|
||||
(void)snprintf(obuff, sizeof(obuff), "%02ld:%02ld:%02ld",
|
||||
(long)hours, (long)mins, (long)secs);
|
||||
}
|
||||
else {
|
||||
(void)snprintf(obuff, sizeof(obuff), "%02ld:%02ld",
|
||||
(long)mins, (long)secs);
|
||||
}
|
||||
(void)printf("%*s", v->width, obuff);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ static const char copyright[] =
|
||||
static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user