summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-09-25 00:30:00 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-09-25 00:30:00 +0000
commit67645a2db6bb159f833f293fee09e096a02515b0 (patch)
tree7f84502ecd0ccb5acd55eefb2a6defede89a0136
parenta354e485daca6f9adc1eb51de86fe818ca01fed9 (diff)
Add -H option to show rthreads, hiding them by default
Diff from uwe@
-rw-r--r--bin/ps/ps.18
-rw-r--r--bin/ps/ps.c15
2 files changed, 15 insertions, 8 deletions
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 2be7f2d5d98..fb23eb2a2a0 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ps.1,v 1.76 2011/07/06 21:42:11 art Exp $
+.\" $OpenBSD: ps.1,v 1.77 2011/09/25 00:29:59 guenther Exp $
.\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
@@ -30,7 +30,7 @@
.\"
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\"
-.Dd $Mdocdate: July 6 2011 $
+.Dd $Mdocdate: September 25 2011 $
.Dt PS 1
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.Nm ps
.Sm off
-.Op Fl aCcehjkLlmrSTuvwx
+.Op Fl aCceHhjkLlmrSTuvwx
.Sm on
.Op Fl M Ar core
.Op Fl N Ar system
@@ -89,6 +89,8 @@ scripts will show as
.Dq sh .
.It Fl e
Display the environment as well.
+.It Fl H
+Also display information about kernel visible 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 96511ee42fd..91e459ff11a 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ps.c,v 1.49 2011/04/10 03:20:58 guenther Exp $ */
+/* $OpenBSD: ps.c,v 1.50 2011/09/25 00:29:59 guenther Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@@ -99,7 +99,7 @@ main(int argc, char *argv[])
pid_t pid;
uid_t uid;
int all, ch, flag, i, fmt, lineno, nentries, mib[6];
- int prtheader, wflag, kflag, what, Uflag, xflg;
+ int prtheader, showthreads, wflag, kflag, what, Uflag, xflg;
char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX];
size_t size;
@@ -114,13 +114,13 @@ main(int argc, char *argv[])
if (argc > 1)
argv[1] = kludge_oldps_options(argv[1]);
- all = fmt = prtheader = wflag = kflag = Uflag = xflg = 0;
+ all = fmt = prtheader = showthreads = wflag = kflag = Uflag = xflg = 0;
pid = -1;
uid = 0;
ttydev = NODEV;
memf = nlistf = swapf = NULL;
while ((ch = getopt(argc, argv,
- "acCeghjkLlM:mN:O:o:p:rSTt:U:uvW:wx")) != -1)
+ "acCegHhjkLlM:mN:O:o:p:rSTt:U:uvW:wx")) != -1)
switch (ch) {
case 'a':
all = 1;
@@ -136,6 +136,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;
@@ -336,6 +339,8 @@ main(int argc, char *argv[])
* for each proc, call each variable output function.
*/
for (i = lineno = 0; i < nentries; i++) {
+ if (showthreads == 0 && (kinfo[i]->p_flag & P_THREAD) != 0)
+ continue;
if (xflg == 0 && ((int)kinfo[i]->p_tdev == NODEV ||
(kinfo[i]->p_flag & P_CONTROLT ) == 0))
continue;
@@ -458,7 +463,7 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "usage: %s [-aCcehjkLlmrSTuvwx] [-M core] [-N system] [-O fmt] [-o fmt] [-p pid]\n",
+ "usage: %s [-aCceHhjkLlmrSTuvwx] [-M core] [-N system] [-O fmt] [-o fmt] [-p pid]\n",
__progname);
(void)fprintf(stderr,
"%-*s[-t tty] [-U username] [-W swap]\n", (int)strlen(__progname) + 8, "");