Add support for the POSIX.2 "args" and "comm" keywords. "args" is just

an alias for "command", and "comm" shows just argv[0] and not the whole
argument list.

Fix for part of PR standards/11224.
This commit is contained in:
simonb 2004-03-27 14:52:36 +00:00
parent 63e11689ca
commit 891960dba2
4 changed files with 21 additions and 13 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: keyword.c,v 1.39 2004/03/27 14:49:13 simonb Exp $ */
/* $NetBSD: keyword.c,v 1.40 2004/03/27 14:52:36 simonb Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: keyword.c,v 1.39 2004/03/27 14:49:13 simonb Exp $");
__RCSID("$NetBSD: keyword.c,v 1.40 2004/03/27 14:52:36 simonb Exp $");
#endif
#endif /* not lint */
@ -96,8 +96,10 @@ VAR var[] = {
{"%mem", "%MEM", 0, pmem, POFF(p_vm_rssize), INT32},
PVAR("acflag", "ACFLG", 0, p_acflag, USHORT, "x"),
{"acflg", "acflag", ALIAS},
{"args", "command", ALIAS},
{"blocked", "sigmask", ALIAS},
{"caught", "sigcatch", ALIAS},
{"comm", "COMMAND", COMM|ARGV0|LJUST, command},
{"command", "COMMAND", COMM|LJUST, command},
PVAR("cpu", "CPU", 0, p_estcpu, UINT, "u"),
{"cputime", "time", ALIAS},

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.87 2004/03/27 14:49:13 simonb Exp $ */
/* $NetBSD: print.c,v 1.88 2004/03/27 14:52:36 simonb Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: print.c,v 1.87 2004/03/27 14:49:13 simonb Exp $");
__RCSID("$NetBSD: print.c,v 1.88 2004/03/27 14:52:36 simonb Exp $");
#endif
#endif /* not lint */
@ -306,8 +306,11 @@ command(void *arg, VARENT *ve, int mode)
fmt_puts(*p, &left);
p++;
fmt_putc(' ', &left);
if (v->flag & ARGV0)
break;
}
if (titlecmp(name, argv)) {
if (!(v->flag & ARGV0) &&
titlecmp(name, argv)) {
/*
* append the real command name within
* parentheses, if the command name

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ps.1,v 1.66 2004/03/27 14:49:13 simonb Exp $
.\" $NetBSD: ps.1,v 1.67 2004/03/27 14:52:36 simonb Exp $
.\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved.
@ -457,8 +457,10 @@ percentage CPU usage (alias pcpu)
percentage memory usage (alias pmem)
.It acflag
accounting flag (alias acflg)
.It comm
command (the argv[0] value)
.It command
command and arguments
command and arguments (alias args)
.It cpu
short-term CPU usage factor (for scheduling)
.It ctime

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.h,v 1.23 2004/03/27 14:09:10 simonb Exp $ */
/* $NetBSD: ps.h,v 1.24 2004/03/27 14:52:36 simonb Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -53,11 +53,12 @@ typedef struct var {
char *name; /* name(s) of variable */
char *header; /* default header */
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define INF127 0x04 /* 127 = infinity: if > 127, print 127. */
#define LWP 0x08 /* dispatch to kinfo_lwp routine */
#define UAREA 0x10 /* need to check p_uvalid */
#define ALIAS 0x20 /* entry is alias for 'header' */
#define ARGV0 0x02 /* only print argv[0] */
#define LJUST 0x04 /* left adjust on output (trailing blanks) */
#define INF127 0x08 /* 127 = infinity: if > 127, print 127. */
#define LWP 0x10 /* dispatch to kinfo_lwp routine */
#define UAREA 0x20 /* need to check p_uvalid */
#define ALIAS 0x40 /* entry is alias for 'header' */
u_int flag;
/* output routine */
void (*oproc)(void *, struct varent *, int);