Implement a -c option to ps to display the short command name instead of

the full argument vector.

I've bumped into a few things that expected this switch to be present,
the most recent was the snmp package in ports.  I'm not 100% sure of the
origins of this, but Linux has it, so does the "BSD-compatable" version
of ps on our SVR4 systems (so I assume SunOS has it too).
This commit is contained in:
peter 1996-10-21 07:30:26 +00:00
parent 0392fde426
commit 8fd01a136e
4 changed files with 24 additions and 11 deletions

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)extern.h 8.3 (Berkeley) 4/2/94
* $Id$
* $Id: extern.h,v 1.2 1994/09/24 02:56:42 davidg Exp $
*/
struct kinfo;
@ -40,7 +40,7 @@ struct var;
struct varent;
extern fixpt_t ccpu;
extern int eval, fscale, mempages, nlistread, rawcpu;
extern int eval, fscale, mempages, nlistread, rawcpu, cflag;
extern int sumrusage, termwidth, totwidth;
extern VAR var[];
extern VARENT *vhead;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: print.c,v 1.14 1996/06/29 08:04:05 peter Exp $
* $Id: print.c,v 1.15 1996/06/29 10:25:31 peter Exp $
*/
#ifndef lint
@ -100,6 +100,13 @@ command(k, ve)
int left;
char *cp, *vis_env, *vis_args;
v = ve->var;
if (cflag) {
(void)printf("%-*s", v->width, KI_PROC(k)->p_comm);
return;
}
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
err(1, NULL);
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
@ -110,7 +117,6 @@ command(k, ve)
} else
vis_env = NULL;
v = ve->var;
if (ve->next == NULL) {
/* last field */
if (termwidth == UNLIMITED) {

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $Id: ps.1,v 1.9 1996/04/19 22:23:27 smpatel Exp $
.\" $Id: ps.1,v 1.10 1996/07/03 22:17:28 mpp Exp $
.\"
.Dd April 18, 1994
.Dt PS 1
@ -40,7 +40,7 @@
.Nd process status
.Sh SYNOPSIS
.Nm \&ps
.Op Fl aCehjlmrSTuvwx
.Op Fl aCcehjlmrSTuvwx
.Op Fl M Ar core
.Op Fl N Ar system
.Op Fl O Ar fmt
@ -79,6 +79,9 @@ The options are as follows:
.Bl -tag -width indent
.It Fl a
Display information about other users' processes as well as your own.
.It Fl c
Change the ``command'' column output to just contain the executable name,
rather than the full command line.
.It Fl C
Change the way the cpu percentage is calculated by using a ``raw''
cpu calculation that ignores ``resident'' time (this normally has

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ps.c,v 1.11 1996/01/12 08:49:43 peter Exp $
* $Id: ps.c,v 1.12 1996/01/20 10:43:54 mpp Exp $
*/
#ifndef lint
@ -77,6 +77,7 @@ KINFO *kinfo;
struct varent *vhead, *vtail;
int eval; /* exit value */
int cflag; /* -c */
int rawcpu; /* -C */
int sumrusage; /* -S */
int termwidth; /* width of screen (0 == infinity) */
@ -139,17 +140,20 @@ main(argc, argv)
ttydev = NODEV;
memf = nlistf = swapf = NULL;
while ((ch = getopt(argc, argv,
"aCeghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF)
"aCceghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF)
switch((char)ch) {
case 'a':
all = 1;
break;
case 'e': /* XXX set ufmt */
needenv = 1;
break;
case 'C':
rawcpu = 1;
break;
case 'c':
cflag = 1;
break;
case 'e': /* XXX set ufmt */
needenv = 1;
break;
case 'g':
break; /* no-op */
case 'h':