summaryrefslogtreecommitdiffstats
path: root/bin/ps
diff options
context:
space:
mode:
authorjmallett <jmallett@FreeBSD.org>2010-03-17 22:57:58 +0000
committerjmallett <jmallett@FreeBSD.org>2010-03-17 22:57:58 +0000
commitd27802f97a217c556ca63d8df9ebc1b6d15ccd19 (patch)
tree231aea4c64247be505190e35fe0e7ae410703755 /bin/ps
parentb55593dee5f64317be6472d0338098432211dbe4 (diff)
downloadFreeBSD-src-d27802f97a217c556ca63d8df9ebc1b6d15ccd19.zip
FreeBSD-src-d27802f97a217c556ca63d8df9ebc1b6d15ccd19.tar.gz
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
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h1
-rw-r--r--bin/ps/keyword.c1
-rw-r--r--bin/ps/print.c16
-rw-r--r--bin/ps/ps.19
4 files changed, 25 insertions, 2 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index c441278..45d76a6 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -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);
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 4524d99..237b579 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -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},
diff --git a/bin/ps/print.c b/bin/ps/print.c
index aa4f98f..cc33cdd 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -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)
{
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 5c9689e..3298cfc 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -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 )
OpenPOWER on IntegriCloud