summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/prstat/prsort.c15
-rw-r--r--usr/src/cmd/prstat/prstat.c14
-rw-r--r--usr/src/man/man1m/prstat.1m10
3 files changed, 26 insertions, 13 deletions
diff --git a/usr/src/cmd/prstat/prsort.c b/usr/src/cmd/prstat/prsort.c
index cf7c250fe1..39ea28d893 100644
--- a/usr/src/cmd/prstat/prsort.c
+++ b/usr/src/cmd/prstat/prsort.c
@@ -22,10 +22,9 @@
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <libintl.h>
#include <stdlib.h>
#include <string.h>
@@ -38,10 +37,11 @@
void
list_alloc(list_t *list, int size)
{
- if (size > 0) {
- list->l_size = size;
+ list->l_size = size;
+ if (size > 0)
list->l_ptrs = Zalloc(sizeof (void *) * (size + 1));
- }
+ else
+ list->l_ptrs = NULL;
}
void
@@ -208,8 +208,11 @@ list_preinsert(list_t *list, void *ptr)
void
list_sort(list_t *list)
{
- (void) memset(list->l_ptrs, 0, sizeof (void *) * list->l_size);
list->l_used = 0;
+ if (list->l_size == 0)
+ return;
+
+ (void) memset(list->l_ptrs, 0, sizeof (void *) * list->l_size);
if (list->l_type == LT_LWPS) {
lwp_info_t *lwp = list->l_head;
diff --git a/usr/src/cmd/prstat/prstat.c b/usr/src/cmd/prstat/prstat.c
index ae02ee9cf8..e14538a57e 100644
--- a/usr/src/cmd/prstat/prstat.c
+++ b/usr/src/cmd/prstat/prstat.c
@@ -367,6 +367,9 @@ list_print(list_t *list)
double loadavg[3] = {0, 0, 0};
int i, lwpid;
+ if (list->l_size == 0)
+ return;
+
if (foreach_element(&set_tbl, &loadavg, psetloadavg) == 0) {
/*
* If processor sets aren't specified, we display system-wide
@@ -1150,7 +1153,10 @@ setmovecur()
return;
}
if (opts.o_outpmode & OPT_SPLIT) {
- n = opts.o_ntop + opts.o_nbottom + 2;
+ if (opts.o_ntop == 0)
+ n = opts.o_nbottom + 1;
+ else
+ n = opts.o_ntop + opts.o_nbottom + 2;
} else {
if (opts.o_outpmode & OPT_USERS)
n = opts.o_nbottom + 1;
@@ -1424,6 +1430,8 @@ main(int argc, char **argv)
opts.o_ntop = Atoi(p);
if (p = strtok(NULL, ","))
opts.o_nbottom = Atoi(p);
+ else if (opts.o_ntop == 0)
+ opts.o_nbottom = 5;
opts.o_outpmode &= ~OPT_FULLSCREEN;
break;
case 's':
@@ -1489,7 +1497,9 @@ main(int argc, char **argv)
if ((opts.o_outpmode & OPT_USERS) &&
!(opts.o_outpmode & OPT_SPLIT))
opts.o_nbottom = opts.o_ntop;
- if (opts.o_ntop == 0 || opts.o_nbottom == 0)
+ if (!(opts.o_outpmode & OPT_SPLIT) && opts.o_ntop == 0)
+ Die(gettext("invalid argument for -n\n"));
+ if (opts.o_nbottom == 0)
Die(gettext("invalid argument for -n\n"));
if (!(opts.o_outpmode & OPT_SPLIT) && (opts.o_outpmode & OPT_USERS) &&
((opts.o_outpmode & (OPT_PSINFO | OPT_MSACCT))))
diff --git a/usr/src/man/man1m/prstat.1m b/usr/src/man/man1m/prstat.1m
index adacc7f980..5b884da8d5 100644
--- a/usr/src/man/man1m/prstat.1m
+++ b/usr/src/man/man1m/prstat.1m
@@ -4,7 +4,7 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with
.\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH PRSTAT 1M "Jun 25, 2009"
+.TH PRSTAT 1M "Sep 5, 2012"
.SH NAME
prstat \- report active process statistics
.SH SYNOPSIS
@@ -174,10 +174,10 @@ waiting for user locks and waiting for \fBCPU\fR (latency time).
.RS 4n
Restrict number of output lines. The \fIntop\fR argument determines how many
lines of process or \fBlwp\fR statistics are reported, and the \fInbottom\fR
-argument determines how many lines of user, task, or projects statistics are
-reported if the \fB-a\fR, \fB-t\fR, \fB-T\fR, or \fB-J\fR options are
-specified. By default, \fBprstat\fR displays as many lines of output that fit
-in a window or terminal. When you specify the \fB-c\fR option or direct the
+argument determines how many lines of user, task, project or zone statistics
+are reported if the \fB-a\fR, \fB-t\fR, \fB-T\fR, \fB-J\fR or \fB-Z\fR options
+are specified. By default, \fBprstat\fR displays as many lines of output that
+fit in a window or terminal. When you specify the \fB-c\fR option or direct the
output to a file, the default values for \fBntop\fR and \fBnbottom\fR are
\fB15\fR and \fB5\fR.
.RE