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

This commit is contained in:
christos 2001-08-07 14:46:09 +00:00
parent 92bef1e82b
commit c91b59d1de
2 changed files with 31 additions and 20 deletions

View File

@ -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 @@ command(ki, ve, mode)
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);

View File

@ -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 @@ is not reliable because a process is allowed to destroy this
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