# HG changeset patch # User Bryan Cantrill # Date 1348136869 0 # Node ID f353227ba62672a98cf3a7207a6bd2745247ed77 # Parent 2ce1147810ed53d181470fe7bc569bc27707ac94 3149 ps should have dmodel as an output format Reviewed by: Robert Mustacchi Reviewed by: Eric Schrock Reviewed by: Jason King Approved by: Dan McDonald diff -r 2ce1147810ed -r f353227ba626 usr/src/cmd/ps/ps.c --- a/usr/src/cmd/ps/ps.c Thu Sep 20 08:39:18 2012 -0700 +++ b/usr/src/cmd/ps/ps.c Thu Sep 20 10:27:49 2012 +0000 @@ -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 @@ 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 @@ { "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 @@ 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 @@ /* 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 -r 2ce1147810ed -r f353227ba626 usr/src/man/man1/ps.1 --- a/usr/src/man/man1/ps.1 Thu Sep 20 08:39:18 2012 -0700 +++ b/usr/src/man/man1/ps.1 Thu Sep 20 10:27:49 2012 +0000 @@ -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 @@ .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.