summaryrefslogtreecommitdiff
path: root/bin/ps
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2010-03-17 22:57:58 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2010-03-17 22:57:58 +0000
commit41ded75de8eae61ebaaa4e8c21dafde14a84ad5a (patch)
tree231aea4c64247be505190e35fe0e7ae410703755 /bin/ps
parentc0df07cad90a9bbad801e23b95ce5a4b0d92062e (diff)
Notes
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 c44127817ffd5..45d76a679fb82 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 4524d99566654..237b579995273 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 aa4f98f2c7bc6..cc33cddfd8cfd 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 5c9689e106385..3298cfc2c9ee0 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 )