summaryrefslogtreecommitdiffstats
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2003-06-12 16:53:55 +0000
committerscottl <scottl@FreeBSD.org>2003-06-12 16:53:55 +0000
commit3b2e1bb3751bd9814f35af9bff681310921e2978 (patch)
treeff1eb0759af7c2dbace2625702e823757f25ce90 /bin/ps/ps.c
parent6eefe73af986e3554a282e0192a619972b220c01 (diff)
downloadFreeBSD-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/ps.c')
-rw-r--r--bin/ps/ps.c17
1 files changed, 12 insertions, 5 deletions
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);
OpenPOWER on IntegriCloud