aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/print.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-06-06 21:18:37 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-06-06 21:18:37 +0000
commit76e1a9fe48b8202078fa822ea267bf03f1f7db1b (patch)
tree018038cc3130503a09bafc00e2621fa02cc01d10 /bin/ps/print.c
parent4049699b954417fc304d57f8b61deec9139949a9 (diff)
downloadsrc-76e1a9fe48b8202078fa822ea267bf03f1f7db1b.tar.gz
src-76e1a9fe48b8202078fa822ea267bf03f1f7db1b.zip
Implement a SUSv3-ignorant but "time"-similar format for "etime", elapsed
run time (NOT cpu time). cputime() and elapsed() both need to honour SUSv3 now.
Notes
Notes: svn path=/head/; revision=97965
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r--bin/ps/print.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c
index e94920658c52..4f43aa4da5e4 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -535,6 +535,23 @@ cputime(KINFO *k, VARENT *ve)
(void)printf("%*s", v->width, obuff);
}
+void
+elapsed(KINFO *k, VARENT *ve)
+{
+ VAR *v;
+ time_t secs;
+ char obuff[128];
+ static time_t now;
+
+ v = ve->var;
+
+ if (!now)
+ time(&now);
+ secs = now - k->ki_p->ki_start.tv_sec;
+ (void)snprintf(obuff, sizeof(obuff), "%3ld:%02ld", secs/60, secs%60);
+ (void)printf("%*s", v->width, obuff);
+}
+
double
getpcpu(const KINFO *k)
{