Subject: bin/148: ps -c option wanted
To: None <gnats-admin>
From: None <arnej@dsl.unit.no>
List: netbsd-bugs
Date: 03/02/1994 08:50:05
>Number:         148
>Category:       bin
>Synopsis:       ps has no c option
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Mar  2 08:50:03 1994
>Originator:     Arne Juul
>Organization:
University of Trondheim, Norway
>Release:        
>Environment:
	NetBSD-current last sup'ed Mar 1 1994
System: NetBSD skarven.dsl.unit.no 0.9a SKARVEN#0 i386


>Description:
	After several years of using BSD-derived systems, I have
	become accustomed to using "ps xgc" and other usages of
	the -c option. NetBSD currently does not implement any such
	option, giving only 'illegal option'. Having the option would
	be nice (but I imagine I could probably get used to it, so
	feel free to munge or junk this patch).
>How-To-Repeat:
	ps -c
>Fix:
	Apply this patch:
diff -rc /usr/src/bin/ps/ps.1 ./ps.1
*** /usr/src/bin/ps/ps.1	Tue Jan 11 11:21:59 1994
--- ./ps.1	Wed Mar  2 17:14:22 1994
***************
*** 40,46 ****
  .Nd process status
  .Sh SYNOPSIS
  .Nm \&ps
! .Op Fl aChjlmrSTuvwx
  .Op Fl M Ar core
  .Op Fl N Ar system
  .Op Fl O Ar fmt
--- 40,46 ----
  .Nd process status
  .Sh SYNOPSIS
  .Nm \&ps
! .Op Fl acChjlmrSTuvwx
  .Op Fl M Ar core
  .Op Fl N Ar system
  .Op Fl O Ar fmt
***************
*** 72,77 ****
--- 72,81 ----
  .Bl -tag -width indent
  .It Fl a
  Display information about other users' processes as well as your own.
+ .It Fl c
+ Do not display full command with arguments, but only the
+ executable name. This may be somewhat confusing - for example, all
+ shell scripts will show as 'sh'.
  .It Fl C
  Change the way the cpu percentage is calculated by using a ``raw''
  cpu calculation that ignores ``resident'' time (this normally has
diff -rc /usr/src/bin/ps/ps.c ./ps.c
*** /usr/src/bin/ps/ps.c	Fri Dec 17 06:48:01 1993
--- ./ps.c	Wed Mar  2 17:18:37 1994
***************
*** 73,79 ****
  int	termwidth;		/* width of screen (0 == infinity) */
  int	totwidth;		/* calculated width of requested variables */
  
! static int needuser, needcomm, needenv;
  
  enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
  
--- 73,79 ----
  int	termwidth;		/* width of screen (0 == infinity) */
  int	totwidth;		/* calculated width of requested variables */
  
! static int needuser, needcomm, needenv, commandonly;
  
  enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT;
  
***************
*** 128,138 ****
  	ttydev = NODEV;
  	memf = nlistf = swapf = NULL;
  	while ((ch = getopt(argc, argv,
! 	    "aCeghjLlM:mN:O:o:p:rSTt:uvW:wx")) != EOF)
  		switch((char)ch) {
  		case 'a':
  			all = 1;
  			break;
  		case 'C':
  			rawcpu = 1;
  			break;
--- 128,141 ----
  	ttydev = NODEV;
  	memf = nlistf = swapf = NULL;
  	while ((ch = getopt(argc, argv,
! 	    "acCeghjLlM:mN:O:o:p:rSTt:uvW:wx")) != EOF)
  		switch((char)ch) {
  		case 'a':
  			all = 1;
  			break;
+ 		case 'c':
+ 			commandonly = 1;
+ 			break;
  		case 'C':
  			rawcpu = 1;
  			break;
***************
*** 362,368 ****
  	/*
  	 * save arguments and environment if needed
  	 */
! 	ki->ki_args = needcomm ? strdup(kvm_getargs(ki->ki_p, up)) : NULL;
  	ki->ki_env = needenv ? strdup(kvm_getenv(ki->ki_p, up)) : NULL;
  
  	if (up != NULL) {
--- 365,379 ----
  	/*
  	 * save arguments and environment if needed
  	 */
! 	if (needcomm) {
! 		if (commandonly) {
! 			ki->ki_args = strdup(ki->ki_p->p_comm);
! 		} else {
! 			ki->ki_args = strdup(kvm_getargs(ki->ki_p, up));
! 		}
! 	} else {
! 		ki->ki_args = NULL;
! 	}
  	ki->ki_env = needenv ? strdup(kvm_getenv(ki->ki_p, up)) : NULL;
  
  	if (up != NULL) {
>Audit-Trail:
>Unformatted:


------------------------------------------------------------------------------