Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ps Print system processes/kernel threads as [kprocname] ...



details:   https://anonhg.NetBSD.org/src/rev/42dc934f0c5b
branches:  trunk
changeset: 513682:42dc934f0c5b
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 07 14:46:09 2001 +0000

description:
Print system processes/kernel threads as [kprocname] as top(1) does.

diffstat:

 bin/ps/print.c |  40 +++++++++++++++++++++++++---------------
 bin/ps/ps.1    |  11 ++++++-----
 2 files changed, 31 insertions(+), 20 deletions(-)

diffs (91 lines):

diff -r 656b6b41e8b9 -r 42dc934f0c5b bin/ps/print.c
--- a/bin/ps/print.c    Tue Aug 07 13:57:41 2001 +0000
+++ b/bin/ps/print.c    Tue Aug 07 14:46:09 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.66 2001/07/14 06:53:44 matt Exp $  */
+/*     $NetBSD: print.c,v 1.67 2001/08/07 14:46:09 christos Exp $      */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c    8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.66 2001/07/14 06:53:44 matt Exp $");
+__RCSID("$NetBSD: print.c,v 1.67 2001/08/07 14:46:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -310,20 +310,30 @@
                                        p++;
                                        fmt_putc(' ', &left);
                                }
-                       }
-                       /*
-                        * append the real command name within
-                        * parentheses, if the command name does
-                        * not match the one in the argument vector
-                        */
-                       if (titlecmp(name, argv)) {
-                               fmt_putc('(', &left);
+                               if (titlecmp(name, argv)) {
+                                       /*
+                                        * append the real command name within
+                                        * parentheses, if the command name 
+                                        * does not match the one in the
+                                        * argument vector
+                                        */
+                                       fmt_putc('(', &left);
+                                       fmt_puts(name, &left);
+                                       fmt_putc(')', &left);
+                               }
+                               if (use_procfs) {
+                                       free(argv[0]);
+                                       free(argv);
+                               }
+                       } else {
+                               /*
+                                * Commands that don't set an argv vector
+                                * (usually system processes) are printed
+                                * with angled brackets.
+                                */
+                               fmt_putc('[', &left);
                                fmt_puts(name, &left);
-                               fmt_putc(')', &left);
-                       }
-                       if (use_procfs && argv) {
-                               free(argv[0]);
-                               free(argv);
+                               fmt_putc(']', &left);
                        }
                } else {
                        fmt_puts(name, &left);
diff -r 656b6b41e8b9 -r 42dc934f0c5b bin/ps/ps.1
--- a/bin/ps/ps.1       Tue Aug 07 13:57:41 2001 +0000
+++ b/bin/ps/ps.1       Tue Aug 07 14:46:09 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: ps.1,v 1.43 2001/07/04 20:49:00 sommerfeld Exp $
+.\"    $NetBSD: ps.1,v 1.44 2001/08/07 14:46:10 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
@@ -389,14 +389,15 @@
 information. The ucomm (accounting) keyword will always contain
 the real command name as contained in the process structure's p_comm field.
 .Pp
+If the command vector cannot be located (usually because it has not
+been set, as is the case of system processes and/or kernel threads)
+the command name is printed within square brackets.
+.Pp
 To indicate that the argument vector has been tampered with,
 .Nm
 will append the real command name to the output within parentheses
 if the basename of the first argument in the argument vector
-does not match the contents of the real command name.  A special
-case of the above is system processes and/or kernel threads
-which are shown within parentheses because they do not set their
-argument vector.
+does not match the contents of the real command name.
 .Pp
 In addition,
 .Nm



Home | Main Index | Thread Index | Old Index