diff options
author | Bryan Cantrill <bryan@joyent.com> | 2012-09-20 10:27:49 +0000 |
---|---|---|
committer | Bryan Cantrill <bryan@joyent.com> | 2012-09-20 10:27:49 +0000 |
commit | eaaa4d5f5eed6a67a490a59a60ac9bacbd3ca78b (patch) | |
tree | 416945ed3702620e227496a89ab81b528c235a0f | |
parent | 1ce39b5f7909b9be3294c026d97221d76b301e88 (diff) | |
download | illumos-joyent-eaaa4d5f5eed6a67a490a59a60ac9bacbd3ca78b.tar.gz |
3149 ps should have dmodel as an output format
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Eric Schrock <eric.schrock@delphix.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
-rw-r--r-- | usr/src/cmd/ps/ps.c | 67 | ||||
-rw-r--r-- | usr/src/man/man1/ps.1 | 11 |
2 files changed, 64 insertions, 14 deletions
diff --git a/usr/src/cmd/ps/ps.c b/usr/src/cmd/ps/ps.c index e607dd5644..19e2d15655 100644 --- a/usr/src/cmd/ps/ps.c +++ b/usr/src/cmd/ps/ps.c @@ -24,6 +24,10 @@ * Use is subject to license terms. */ +/* + * Copyright (c) 2012, Joyent, Inc. All rights reserved. + */ + /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ @@ -130,7 +134,8 @@ enum fname { /* enumeration of field names */ F_ZONE, /* zone name */ F_ZONEID, /* zone id */ F_CTID, /* process contract id */ - F_LGRP /* process home lgroup */ + F_LGRP, /* process home lgroup */ + F_DMODEL /* process data model */ }; struct field { @@ -204,6 +209,7 @@ static struct def_field fname[] = { { "zoneid", "ZONEID", 5, 5 }, { "ctid", "CTID", 5, 5 }, { "lgrp", "LGRP", 4, 2 }, + { "dmodel", "DMODEL", 6, 6 }, }; #define NFIELDS (sizeof (fname) / sizeof (fname[0])) @@ -1035,33 +1041,61 @@ retry: return (0); } +static int +field_cmp(const void *l, const void *r) +{ + struct def_field *lhs = *((struct def_field **)l); + struct def_field *rhs = *((struct def_field **)r); + + return (strcmp(lhs->fname, rhs->fname)); +} static void usage(void) /* print usage message and quit */ { + struct def_field *df, *sorted[NFIELDS]; + int pos = 80, i = 0; + static char usage1[] = "ps [ -aAdefHlcjLPyZ ] [ -o format ] [ -t termlist ]"; static char usage2[] = "\t[ -u userlist ] [ -U userlist ] [ -G grouplist ]"; static char usage3[] = - "\t[ -p proclist ] [ -g pgrplist ] [ -s sidlist ] [ -z zonelist ] " - "[-h lgrplist]"; + "\t[ -p proclist ] [ -g pgrplist ] [ -s sidlist ]"; static char usage4[] = - " 'format' is one or more of:"; + "\t[ -z zonelist ] [-h lgrplist]"; static char usage5[] = - "\tuser ruser group rgroup uid ruid gid rgid pid ppid pgid " - "sid taskid ctid"; - static char usage6[] = - "\tpri opri pcpu pmem vsz rss osz nice class time etime stime zone " - "zoneid"; - static char usage7[] = - "\tf s c lwp nlwp psr tty addr wchan fname comm args " - "projid project pset lgrp"; + " 'format' is one or more of:"; (void) fprintf(stderr, - gettext("usage: %s\n%s\n%s\n%s\n%s\n%s\n%s\n"), + gettext("usage: %s\n%s\n%s\n%s\n%s"), gettext(usage1), gettext(usage2), gettext(usage3), - gettext(usage4), gettext(usage5), gettext(usage6), gettext(usage7)); + gettext(usage4), gettext(usage5)); + + /* + * Now print out the possible output formats such that they neatly fit + * into eighty columns. Note that the fact that we are determining + * this output programmatically means that a gettext() is impossible -- + * but it would be a mistake to localize the output formats anyway as + * they are tokens for input, not output themselves. + */ + for (df = &fname[0]; df < &fname[NFIELDS]; df++) + sorted[i++] = df; + + (void) qsort(sorted, NFIELDS, sizeof (void *), field_cmp); + + for (i = 0; i < NFIELDS; i++) { + if (pos + strlen((df = sorted[i])->fname) + 1 >= 80) { + (void) fprintf(stderr, "\n\t"); + pos = 8; + } + + (void) fprintf(stderr, "%s%s", pos > 8 ? " " : "", df->fname); + pos += strlen(df->fname) + 1; + } + + (void) fprintf(stderr, "\n"); + exit(1); } @@ -1886,6 +1920,11 @@ print_field(psinfo_t *psinfo, struct field *f, const char *ttyp) /* Display home lgroup */ (void) printf("%*d", width, (int)psinfo->pr_lwp.pr_lgrp); break; + + case F_DMODEL: + (void) printf("%*s", width, + psinfo->pr_dmodel == PR_MODEL_LP64 ? "_LP64" : "_ILP32"); + break; } } diff --git a/usr/src/man/man1/ps.1 b/usr/src/man/man1/ps.1 index 5e8c1b9be0..8e97b196c2 100644 --- a/usr/src/man/man1/ps.1 +++ b/usr/src/man/man1/ps.1 @@ -1,6 +1,7 @@ '\" te .\" Copyright 1989 AT&T .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved +.\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text @@ -1095,6 +1096,16 @@ The home lgroup of the process. .RE .sp +.ne 2 +.na +\fB\fBdmodel\fR\fR +.ad +.RS 11n +The data model of the process, printed in the same manner as via +\fBpflags\fR(1). The currently supported data models are _ILP32 and _LP64. +.RE + +.sp .LP Only \fBcomm\fR and \fBargs\fR are allowed to contain blank characters; all others, including the Solaris implementation variables, are not. |