diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-06-06 21:18:37 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-06-06 21:18:37 +0000 |
commit | becd81c4a9315cc0cfd6078a89434a5ed7091e28 (patch) | |
tree | 018038cc3130503a09bafc00e2621fa02cc01d10 /bin/ps/print.c | |
parent | b00060629b3ce16fbaae1856247191506fb052e0 (diff) | |
download | FreeBSD-src-becd81c4a9315cc0cfd6078a89434a5ed7091e28.zip FreeBSD-src-becd81c4a9315cc0cfd6078a89434a5ed7091e28.tar.gz |
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.
Diffstat (limited to 'bin/ps/print.c')
-rw-r--r-- | bin/ps/print.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index e949206..4f43aa4 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) { |