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.
This commit is contained in:
Scott Long 2003-06-12 16:53:55 +00:00
parent 35066b41da
commit 48b8c0de5a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116265
2 changed files with 19 additions and 6 deletions

View File

@ -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.

View File

@ -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);