summaryrefslogtreecommitdiff
path: root/usr/src/cmd/prstat/prstat.c
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2012-09-05 22:15:06 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2012-09-05 22:15:06 +0000
commit6d3ed4f3519d4776784e74ab84d9b0661d67f0ca (patch)
treeb5199a07ed244924a63e8f4edb2e54b3a6e36b58 /usr/src/cmd/prstat/prstat.c
parent68ecce0663a66abcf57fc279a66f98bbf6e8ab01 (diff)
downloadillumos-joyent-6d3ed4f3519d4776784e74ab84d9b0661d67f0ca.tar.gz
OS-1519 prstat -n option should accept 0
reviewed by Robert Mustacchi
Diffstat (limited to 'usr/src/cmd/prstat/prstat.c')
-rw-r--r--usr/src/cmd/prstat/prstat.c14
1 files changed, 12 insertions, 2 deletions
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))))