summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-10-21 07:30:26 +0000
committerpeter <peter@FreeBSD.org>1996-10-21 07:30:26 +0000
commit8fd01a136e847689c60d19cd8d439b37c9a7b5a9 (patch)
tree6da5843225e613b5eb4f4456c650f4b7576cd2de /bin
parent0392fde42645c8d1db15c97f3b45d1faa9f96b1c (diff)
downloadFreeBSD-src-8fd01a136e847689c60d19cd8d439b37c9a7b5a9.zip
FreeBSD-src-8fd01a136e847689c60d19cd8d439b37c9a7b5a9.tar.gz
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).
Diffstat (limited to 'bin')
-rw-r--r--bin/ps/extern.h4
-rw-r--r--bin/ps/print.c10
-rw-r--r--bin/ps/ps.17
-rw-r--r--bin/ps/ps.c14
4 files changed, 24 insertions, 11 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index 173ddf3..0dbda2f 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -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;
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 5c01f30..0d5a09f 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -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) {
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 33756b8..e9bbf9f 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -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
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 0586471..6f59124 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -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':
OpenPOWER on IntegriCloud