Date: Wed, 17 Mar 2010 22:57:58 +0000 (UTC) From: Juli Mallett <jmallett@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r205271 - head/bin/ps Message-ID: <201003172257.o2HMvwiZ042273@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jmallett Date: Wed Mar 17 22:57:58 2010 New Revision: 205271 URL: http://svn.freebsd.org/changeset/base/205271 Log: o) Add a keyword to displaying elapsed time in integer seconds, "etimes". o) Give slightly better (i.e. any) documentation of the format of "etime". Reviewed by: jilles Modified: head/bin/ps/extern.h head/bin/ps/keyword.c head/bin/ps/print.c head/bin/ps/ps.1 Modified: head/bin/ps/extern.h ============================================================================== --- head/bin/ps/extern.h Wed Mar 17 22:45:53 2010 (r205270) +++ head/bin/ps/extern.h Wed Mar 17 22:57:58 2010 (r205271) @@ -48,6 +48,7 @@ void command(KINFO *, VARENT *); void cputime(KINFO *, VARENT *); int donlist(void); void elapsed(KINFO *, VARENT *); +void elapseds(KINFO *, VARENT *); void emulname(KINFO *, VARENT *); VARENT *find_varentry(VAR *); const char *fmt_argv(char **, char *, size_t); Modified: head/bin/ps/keyword.c ============================================================================== --- head/bin/ps/keyword.c Wed Mar 17 22:45:53 2010 (r205270) +++ head/bin/ps/keyword.c Wed Mar 17 22:57:58 2010 (r205271) @@ -89,6 +89,7 @@ static VAR var[] = { {"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR, NULL, 0}, {"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0}, + {"etimes", "ELAPSED", NULL, USER, elapseds, 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}, Modified: head/bin/ps/print.c ============================================================================== --- head/bin/ps/print.c Wed Mar 17 22:45:53 2010 (r205270) +++ head/bin/ps/print.c Wed Mar 17 22:57:58 2010 (r205271) @@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$"); #include <nlist.h> #include <pwd.h> #include <stddef.h> +#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -618,6 +619,21 @@ elapsed(KINFO *k, VARENT *ve) (void)printf("%*s", v->width, obuff); } +void +elapseds(KINFO *k, VARENT *ve) +{ + VAR *v; + time_t val; + + v = ve->var; + if (!k->ki_valid) { + (void)printf("%-*s", v->width, "-"); + return; + } + val = now - k->ki_p->ki_start.tv_sec; + (void)printf("%*jd", v->width, (intmax_t)val); +} + double getpcpu(const KINFO *k) { Modified: head/bin/ps/ps.1 ============================================================================== --- head/bin/ps/ps.1 Wed Mar 17 22:45:53 2010 (r205270) +++ head/bin/ps/ps.1 Wed Mar 17 22:57:58 2010 (r205271) @@ -29,7 +29,7 @@ .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd March 5, 2010 +.Dd March 17, 2010 .Dt PS 1 .Os .Sh NAME @@ -479,7 +479,12 @@ command and arguments .It Cm cpu short-term CPU usage factor (for scheduling) .It Cm etime -elapsed running time +elapsed running time, format +.Op days- Ns +.Op hours: Ns +minutes:seconds. +.It Cm etimes +elapsed running time, in decimal integer seconds .It Cm flags the process flags, in hexadecimal (alias .Cm f )
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003172257.o2HMvwiZ042273>