diff options
author | scottl <scottl@FreeBSD.org> | 2003-06-12 16:53:55 +0000 |
---|---|---|
committer | scottl <scottl@FreeBSD.org> | 2003-06-12 16:53:55 +0000 |
commit | 3b2e1bb3751bd9814f35af9bff681310921e2978 (patch) | |
tree | ff1eb0759af7c2dbace2625702e823757f25ce90 /bin/ps | |
parent | 6eefe73af986e3554a282e0192a619972b220c01 (diff) | |
download | FreeBSD-src-3b2e1bb3751bd9814f35af9bff681310921e2978.zip FreeBSD-src-3b2e1bb3751bd9814f35af9bff681310921e2978.tar.gz |
Add the -H option to ps(1) to display all kernel visible threads in each
process. The default behavior of showing only the process is retained as
the default.
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/ps.1 | 8 | ||||
-rw-r--r-- | bin/ps/ps.c | 17 |
2 files changed, 19 insertions, 6 deletions
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 9a6dad2..c348e06 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -40,7 +40,7 @@ .Nd process status .Sh SYNOPSIS .Nm -.Op Fl aCcefhjlmrSTuvwxZ +.Op Fl aCcefHhjlmrSTuvwxZ .Op Fl M Ar core .Op Fl N Ar system .Op Fl O Ar fmt @@ -98,6 +98,12 @@ Display the environment as well. .It Fl f Show commandline and environment information about swapped out processes. This option is honored only if the uid of the user is 0. +.It Fl H +Show all of the +.Em kernel visible +threads associated with each process. Depending on the threading package that +is in use, this may show only the process, only the kernel scheduled entities, +or all of the process threads. .It Fl h Repeat the information header as often as necessary to guarantee one header per page of information. diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 4896c4b..b288d71 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -113,9 +113,9 @@ static char Zfmt[] = "label"; static kvm_t *kd; #if defined(LAZY_PS) -#define PS_ARGS "aCcefghjLlM:mN:O:o:p:rSTt:U:uvwxZ" +#define PS_ARGS "aCcefgHhjLlM:mN:O:o:p:rSTt:U:uvwxZ" #else -#define PS_ARGS "aCceghjLlM:mN:O:o:p:rSTt:U:uvwxZ" +#define PS_ARGS "aCcegHhjLlM:mN:O:o:p:rSTt:U:uvwxZ" #endif int @@ -128,7 +128,7 @@ main(int argc, char *argv[]) pid_t pid; uid_t *uids; int all, ch, flag, i, _fmt, lineno, nentries, nocludge, dropgid; - int prtheader, wflag, what, xflg, uid, nuids; + int prtheader, wflag, what, xflg, uid, nuids, showthreads; char *cols; char errbuf[_POSIX2_LINE_MAX]; const char *cp, *nlistf, *memf; @@ -174,6 +174,7 @@ main(int argc, char *argv[]) ttydev = NODEV; dropgid = 0; memf = nlistf = _PATH_DEVNULL; + showthreads = 0; while ((ch = getopt(argc, argv, PS_ARGS)) != -1) switch((char)ch) { case 'a': @@ -190,6 +191,9 @@ main(int argc, char *argv[]) break; case 'g': break; /* no-op */ + case 'H': + showthreads = 1; + break; case 'h': prtheader = ws.ws_row > 5 ? ws.ws_row : 22; break; @@ -353,9 +357,12 @@ main(int argc, char *argv[]) } else if (pid != -1) { what = KERN_PROC_PID; flag = pid; - } else { + } else if (showthreads == 1) { what = KERN_PROC_ALL; flag = 0; + } else { + what = KERN_PROC_PROC; + flag = 0; } /* * select procs @@ -664,7 +671,7 @@ usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: ps [-aChjlmrSTuvwxZ] [-O|o fmt] [-p pid] [-t tty] [-U user]", + "usage: ps [-aCHhjlmrSTuvwxZ] [-O|o fmt] [-p pid] [-t tty] [-U user]", " [-M core] [-N system]", " ps [-L]"); exit(1); |