From 891960dba2ceae2131fdb30cc44483dd348cf357 Mon Sep 17 00:00:00 2001 From: simonb Date: Sat, 27 Mar 2004 14:52:36 +0000 Subject: [PATCH] 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. --- bin/ps/keyword.c | 6 ++++-- bin/ps/print.c | 9 ++++++--- bin/ps/ps.1 | 6 ++++-- bin/ps/ps.h | 13 +++++++------ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index e603b760c46c..114f600f6ce1 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -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}, diff --git a/bin/ps/print.c b/bin/ps/print.c index c711571959e7..360b6d76efb9 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -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 diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index f78a84ca8fb5..194b3e892cbd 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -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 diff --git a/bin/ps/ps.h b/bin/ps/ps.h index 0ad0c7650a47..030f2ee3ccf4 100644 --- a/bin/ps/ps.h +++ b/bin/ps/ps.h @@ -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);