- I missed usage(), pointed out by jmc
- Sq macro in man page

Index: bin/ps/ps.1
===================================================================
RCS file: /cvs/src/bin/ps/ps.1,v
retrieving revision 1.76
diff -u -p -r1.76 ps.1
--- bin/ps/ps.1 6 Jul 2011 21:42:11 -0000       1.76
+++ bin/ps/ps.1 31 Aug 2011 09:01:06 -0000
@@ -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,12 @@ scripts will show as
 .Dq sh .
 .It Fl e
 Display the environment as well.
+.It Fl H
+Also display information about kernel visible process threads.
+This flag only applies when the
+.Sq kern.rthreads
+sysctl variable is non-zero and there are processes that use kernel
+threading.
 .It Fl h
 Repeat the information header as often as necessary to guarantee one
 header per page of information.
Index: bin/ps/ps.c
===================================================================
RCS file: /cvs/src/bin/ps/ps.c,v
retrieving revision 1.49
diff -u -p -r1.49 ps.c
--- bin/ps/ps.c 10 Apr 2011 03:20:58 -0000      1.49
+++ bin/ps/ps.c 31 Aug 2011 08:54:52 -0000
@@ -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,14 @@ 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 = 0;
+       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 +137,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 +340,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 +464,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, "");

Reply via email to