diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2012-04-04 16:13:12 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2012-04-04 16:13:12 +0000 |
commit | d0ebd0cc207709d8141e262402d39e9467d3f10c (patch) | |
tree | 125519f956e02fdc5ba94814c19cc8b0a80be0b8 | |
parent | cacc94cfadcbe5ced13da57c1ebad41ae8364a38 (diff) |
Add "tid" as a formatting keyword. If the -H option is specified, include
the thread ID in the default format.
ok deraadt@ sthen@
-rw-r--r-- | bin/ps/keyword.c | 8 | ||||
-rw-r--r-- | bin/ps/ps.c | 11 |
2 files changed, 15 insertions, 4 deletions
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index df81cdf948b..0b15a83e6bd 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -1,4 +1,4 @@ -/* $OpenBSD: keyword.c,v 1.35 2012/01/07 05:38:12 guenther Exp $ */ +/* $OpenBSD: keyword.c,v 1.36 2012/04/04 16:13:11 jsing Exp $ */ /* $NetBSD: keyword.c,v 1.12.6.1 1996/05/30 21:25:13 cgd Exp $ */ /*- @@ -75,6 +75,11 @@ int utime(), stime(), ixrss(), idrss(), isrss(); #define PID(n1, n2, fn, off) \ { n1, n2, NULL, 0, fn, PIDLEN, 0, off, INT32, PIDFMT } +#define TIDFMT "d" +#define TIDLEN 7 +#define TID(n1, n2, fn, off) \ + { n1, n2, NULL, 0, fn, TIDLEN, 0, off, INT32, TIDFMT } + #define USERLEN 8 #define CWDLEN 40 @@ -163,6 +168,7 @@ VAR var[] = { GID("svgid", "SVGID", pvar, POFF(p_svgid)), UID("svuid", "SVUID", pvar, POFF(p_svuid)), {"tdev", "TDEV", NULL, 0, tdev, 4}, + TID("tid", "TID", pvar, POFF(p_tid)), {"time", "TIME", NULL, USER, cputime, 9}, PID("tpgid", "TPGID", pvar, POFF(p_tpgid)), {"tsess", "TSESS", NULL, 0, pvar, PTRWIDTH, 0, POFF(p_tsess), UINT64, "llx"}, diff --git a/bin/ps/ps.c b/bin/ps/ps.c index d4f90a48b66..e7edcc3895f 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.51 2011/10/13 01:15:04 guenther Exp $ */ +/* $OpenBSD: ps.c,v 1.52 2012/04/04 16:13:11 jsing Exp $ */ /* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */ /*- @@ -74,6 +74,7 @@ static void scanvars(void); static void usage(void); char dfmt[] = "pid tt state time command"; +char tfmt[] = "pid tid tt state time command"; char jfmt[] = "user pid ppid pgid sess jobc state tt time command"; char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command"; char o1[] = "pid"; @@ -265,8 +266,12 @@ main(int argc, char *argv[]) if (kd == NULL) errx(1, "%s", errbuf); - if (!fmt) - parsefmt(dfmt); + if (!fmt) { + if (showthreads) + parsefmt(tfmt); + else + parsefmt(dfmt); + } /* XXX - should be cleaner */ if (!all && ttydev == NODEV && pid == -1 && !Uflag) { |