Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*


  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  *
  26  * Portions Copyright 2009 Chad Mynhier
  27  */
  28 
  29 #include <sys/types.h>
  30 #include <sys/resource.h>
  31 #include <sys/loadavg.h>
  32 #include <sys/time.h>
  33 #include <sys/pset.h>
  34 #include <sys/vm_usage.h>
  35 #include <zone.h>
  36 #include <libzonecfg.h>
  37 
  38 #include <stdio.h>
  39 #include <stdlib.h>
  40 #include <unistd.h>
  41 #include <dirent.h>
  42 #include <string.h>


  58 #include "prtable.h"
  59 #include "prsort.h"
  60 #include "prfile.h"
  61 
  62 /*
  63  * x86 <sys/regs.h> ERR conflicts with <curses.h> ERR.  For the purposes
  64  * of this file, we care about the curses.h ERR so include that last.
  65  */
  66 
  67 #if     defined(ERR)
  68 #undef  ERR
  69 #endif
  70 
  71 #ifndef TEXT_DOMAIN                     /* should be defined by cc -D */
  72 #define TEXT_DOMAIN     "SYS_TEST"      /* use this only if it wasn't */
  73 #endif
  74 
  75 #include <curses.h>
  76 #include <term.h>
  77 




  78 #define PSINFO_HEADER_PROC \
  79 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       "
  80 #define PSINFO_HEADER_PROC_LGRP \
  81 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU LGRP PROCESS/NLWP  "
  82 #define PSINFO_HEADER_LWP \
  83 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/LWPID      "
  84 #define PSINFO_HEADER_LWP_LGRP \
  85 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU LGRP PROCESS/LWPID "
  86 #define USAGE_HEADER_PROC \
  87 "   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/NLWP  "
  88 #define USAGE_HEADER_LWP \
  89 "   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID "
  90 #define USER_HEADER_PROC \
  91 " NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU                             "
  92 #define USER_HEADER_LWP \
  93 "  NLWP USERNAME  SWAP   RSS MEMORY      TIME  CPU                             "
  94 #define TASK_HEADER_PROC \
  95 "TASKID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
  96 #define TASK_HEADER_LWP \
  97 "TASKID     NLWP  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
  98 #define PROJECT_HEADER_PROC \
  99 "PROJID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 100 #define PROJECT_HEADER_LWP \
 101 "PROJID     NLWP  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 102 #define ZONE_HEADER_PROC \
 103 "ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                        "
 104 #define ZONE_HEADER_LWP \
 105 "ZONEID     NLWP  SWAP   RSS MEMORY      TIME  CPU ZONE                        "
 106 #define PSINFO_LINE \
 107 "%6d %-8s %5s %5s %-6s %3s  %3s %9s %3.3s%% %-.16s/%d"
 108 #define PSINFO_LINE_LGRP \
 109 "%6d %-8s %5s %5s %-6s %3s  %3s %9s %3.3s%% %4d %-.16s/%d"
 110 #define USAGE_LINE \
 111 "%6d %-8s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s "\
 112 "%3.3s %-.12s/%d"
 113 #define USER_LINE \
 114 "%6d %-8s %5.5s %5.5s   %3.3s%% %9s %3.3s%%"
 115 #define TASK_LINE \
 116 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 117 #define PROJECT_LINE \
 118 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 119 #define ZONE_LINE \
 120 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 121 
 122 #define TOTAL_LINE \
 123 "Total: %d processes, %d lwps, load averages: %3.2f, %3.2f, %3.2f"
 124 
 125 /* global variables */
 126 
 127 static char     *t_ulon;                        /* termcap: start underline */
 128 static char     *t_uloff;                       /* termcap: end underline */
 129 static char     *t_up;                          /* termcap: cursor 1 line up */
 130 static char     *t_eol;                         /* termcap: clear end of line */
 131 static char     *t_smcup;                       /* termcap: cursor mvcap on */
 132 static char     *t_rmcup;                       /* termcap: cursor mvcap off */


 337                  * If no match is found, prstat will use the size already
 338                  * gathered from psinfo.
 339                  */
 340         }
 341         free(results);
 342 }
 343 
 344 /*
 345  * A routine to display the contents of the list on the screen
 346  */
 347 static void
 348 list_print(list_t *list)
 349 {
 350         lwp_info_t *lwp;
 351         id_info_t *id;
 352         char usr[4], sys[4], trp[4], tfl[4];
 353         char dfl[4], lck[4], slp[4], lat[4];
 354         char vcx[4], icx[4], scl[4], sig[4];
 355         char psize[6], prssize[6], pmem[6], pcpu[6], ptime[12];
 356         char pstate[7], pnice[4], ppri[4];
 357         char pname[LOGNAME_MAX+1];
 358         char projname[PROJNAME_MAX+1];
 359         char zonename[ZONENAME_MAX+1];
 360         float cpu, mem;
 361         double loadavg[3] = {0, 0, 0};
 362         int i, lwpid;
 363 
 364         if (foreach_element(&set_tbl, &loadavg, psetloadavg) == 0) {
 365                 /*
 366                  * If processor sets aren't specified, we display system-wide
 367                  * load averages.
 368                  */
 369                 (void) getloadavg(loadavg, 3);
 370         }
 371 
 372         if (((opts.o_outpmode & OPT_UDATE) || (opts.o_outpmode & OPT_DDATE)) &&
 373             ((list->l_type == LT_LWPS) || !(opts.o_outpmode & OPT_SPLIT)))
 374                 print_timestamp();
 375         if (opts.o_outpmode & OPT_TTY)
 376                 (void) putchar('\r');
 377         (void) putp(t_ulon);


 429         (void) putchar('\n');
 430 
 431         for (i = 0; i < list->l_used; i++) {
 432                 switch (list->l_type) {
 433                 case LT_PROJECTS:
 434                 case LT_TASKS:
 435                 case LT_USERS:
 436                 case LT_ZONES:
 437                         id = list->l_ptrs[i];
 438                         /*
 439                          * CPU usage and memory usage normalization
 440                          */
 441                         if (total_cpu >= 100)
 442                                 cpu = (100 * id->id_pctcpu) / total_cpu;
 443                         else
 444                                 cpu = id->id_pctcpu;
 445                         if (id->id_sizematch == B_FALSE && total_mem >= 100)
 446                                 mem = (100 * id->id_pctmem) / total_mem;
 447                         else
 448                                 mem = id->id_pctmem;
 449                         if (list->l_type == LT_USERS)
 450                                 pwd_getname(id->id_uid, pname, LOGNAME_MAX + 1,
 451                                     opts.o_outpmode & OPT_NORESOLVE);
 452                         else if (list->l_type == LT_ZONES)


 453                                 getzonename(id->id_zoneid, zonename,
 454                                     ZONENAME_MAX);
 455                         else


 456                                 getprojname(id->id_projid, projname,
 457                                     PROJNAME_MAX,
 458                                     opts.o_outpmode & OPT_NORESOLVE);



 459                         Format_size(psize, id->id_size, 6);
 460                         Format_size(prssize, id->id_rssize, 6);
 461                         Format_pct(pmem, mem, 4);
 462                         Format_pct(pcpu, cpu, 4);
 463                         Format_time(ptime, id->id_time, 10);
 464                         if (opts.o_outpmode & OPT_TTY)
 465                                 (void) putchar('\r');
 466                         if (list->l_type == LT_PROJECTS)
 467                                 (void) printf(PROJECT_LINE, (int)id->id_projid,
 468                                     id->id_nproc, psize, prssize, pmem, ptime,
 469                                     pcpu, projname);
 470                         else if (list->l_type == LT_TASKS)
 471                                 (void) printf(TASK_LINE, (int)id->id_taskid,
 472                                     id->id_nproc, psize, prssize, pmem, ptime,
 473                                     pcpu, projname);
 474                         else if (list->l_type == LT_ZONES)
 475                                 (void) printf(ZONE_LINE, (int)id->id_zoneid,
 476                                     id->id_nproc, psize, prssize, pmem, ptime,
 477                                     pcpu, zonename);
 478                         else
 479                                 (void) printf(USER_LINE, id->id_nproc, pname,
 480                                     psize, prssize, pmem, ptime, pcpu);
 481                         (void) putp(t_eol);
 482                         (void) putchar('\n');
 483                         break;
 484                 case LT_LWPS:
 485                         lwp = list->l_ptrs[i];
 486                         if (opts.o_outpmode & OPT_LWPS)
 487                                 lwpid = lwp->li_info.pr_lwp.pr_lwpid;
 488                         else
 489                                 lwpid = lwp->li_info.pr_nlwp +
 490                                     lwp->li_info.pr_nzomb;
 491                         pwd_getname(lwp->li_info.pr_uid, pname, LOGNAME_MAX + 1,
 492                             opts.o_outpmode & OPT_NORESOLVE);


 493                         if (opts.o_outpmode & OPT_PSINFO) {
 494                                 Format_size(psize, lwp->li_info.pr_size, 6);
 495                                 Format_size(prssize, lwp->li_info.pr_rssize, 6);
 496                                 Format_state(pstate,
 497                                     lwp->li_info.pr_lwp.pr_sname,
 498                                     lwp->li_info.pr_lwp.pr_onpro, 7);
 499                                 if (strcmp(lwp->li_info.pr_lwp.pr_clname,
 500                                     "RT") == 0 ||
 501                                     strcmp(lwp->li_info.pr_lwp.pr_clname,
 502                                     "SYS") == 0 ||
 503                                     lwp->li_info.pr_lwp.pr_sname == 'Z')
 504                                         (void) strcpy(pnice, "  -");
 505                                 else
 506                                         Format_num(pnice,
 507                                             lwp->li_info.pr_lwp.pr_nice - NZERO,
 508                                             4);
 509                                 Format_num(ppri, lwp->li_info.pr_lwp.pr_pri, 4);
 510                                 Format_pct(pcpu,
 511                                     FRC2PCT(lwp->li_info.pr_lwp.pr_pctcpu), 4);
 512                                 if (opts.o_outpmode & OPT_LWPS)
 513                                         Format_time(ptime,
 514                                             lwp->li_info.pr_lwp.pr_time.tv_sec,
 515                                             10);
 516                                 else
 517                                         Format_time(ptime,
 518                                             lwp->li_info.pr_time.tv_sec, 10);
 519                                 if (opts.o_outpmode & OPT_TTY)
 520                                         (void) putchar('\r');
 521                                 stripfname(lwp->li_info.pr_fname);
 522                                 if (opts.o_outpmode & OPT_LGRP) {
 523                                         (void) printf(PSINFO_LINE_LGRP,
 524                                             (int)lwp->li_info.pr_pid, pname,
 525                                             psize, prssize, pstate, ppri, pnice,
 526                                             ptime, pcpu,
 527                                             (int)lwp->li_info.pr_lwp.pr_lgrp,
 528                                             lwp->li_info.pr_fname, lwpid);
 529                                 } else {
 530                                         (void) printf(PSINFO_LINE,
 531                                             (int)lwp->li_info.pr_pid, pname,
 532                                             psize, prssize, pstate, ppri, pnice,

 533                                             ptime, pcpu,
 534                                             lwp->li_info.pr_fname, lwpid);
 535                                 }
 536                                 (void) putp(t_eol);
 537                                 (void) putchar('\n');
 538                         }
 539                         if (opts.o_outpmode & OPT_MSACCT) {
 540                                 Format_pct(usr, lwp->li_usr, 4);
 541                                 Format_pct(sys, lwp->li_sys, 4);
 542                                 Format_pct(slp, lwp->li_slp, 4);
 543                                 Format_num(vcx, lwp->li_vcx, 4);
 544                                 Format_num(icx, lwp->li_icx, 4);
 545                                 Format_num(scl, lwp->li_scl, 4);
 546                                 Format_num(sig, lwp->li_sig, 4);
 547                                 Format_pct(trp, lwp->li_trp, 4);
 548                                 Format_pct(tfl, lwp->li_tfl, 4);
 549                                 Format_pct(dfl, lwp->li_dfl, 4);
 550                                 Format_pct(lck, lwp->li_lck, 4);
 551                                 Format_pct(lat, lwp->li_lat, 4);
 552                                 if (opts.o_outpmode & OPT_TTY)




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2013 Gary Mills
  24  *
  25  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  26  * Use is subject to license terms.
  27  *
  28  * Portions Copyright 2009 Chad Mynhier
  29  */
  30 
  31 #include <sys/types.h>
  32 #include <sys/resource.h>
  33 #include <sys/loadavg.h>
  34 #include <sys/time.h>
  35 #include <sys/pset.h>
  36 #include <sys/vm_usage.h>
  37 #include <zone.h>
  38 #include <libzonecfg.h>
  39 
  40 #include <stdio.h>
  41 #include <stdlib.h>
  42 #include <unistd.h>
  43 #include <dirent.h>
  44 #include <string.h>


  60 #include "prtable.h"
  61 #include "prsort.h"
  62 #include "prfile.h"
  63 
  64 /*
  65  * x86 <sys/regs.h> ERR conflicts with <curses.h> ERR.  For the purposes
  66  * of this file, we care about the curses.h ERR so include that last.
  67  */
  68 
  69 #if     defined(ERR)
  70 #undef  ERR
  71 #endif
  72 
  73 #ifndef TEXT_DOMAIN                     /* should be defined by cc -D */
  74 #define TEXT_DOMAIN     "SYS_TEST"      /* use this only if it wasn't */
  75 #endif
  76 
  77 #include <curses.h>
  78 #include <term.h>
  79 
  80 #define LOGIN_WIDTH     8
  81 #define ZONE_WIDTH      28
  82 #define PROJECT_WIDTH   28
  83 
  84 #define PSINFO_HEADER_PROC \
  85 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP       "
  86 #define PSINFO_HEADER_PROC_LGRP \
  87 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU LGRP PROCESS/NLWP  "
  88 #define PSINFO_HEADER_LWP \
  89 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/LWPID      "
  90 #define PSINFO_HEADER_LWP_LGRP \
  91 "   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU LGRP PROCESS/LWPID "
  92 #define USAGE_HEADER_PROC \
  93 "   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/NLWP  "
  94 #define USAGE_HEADER_LWP \
  95 "   PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID "
  96 #define USER_HEADER_PROC \
  97 " NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU                             "
  98 #define USER_HEADER_LWP \
  99 "  NLWP USERNAME  SWAP   RSS MEMORY      TIME  CPU                             "
 100 #define TASK_HEADER_PROC \
 101 "TASKID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 102 #define TASK_HEADER_LWP \
 103 "TASKID     NLWP  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 104 #define PROJECT_HEADER_PROC \
 105 "PROJID    NPROC  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 106 #define PROJECT_HEADER_LWP \
 107 "PROJID     NLWP  SWAP   RSS MEMORY      TIME  CPU PROJECT                     "
 108 #define ZONE_HEADER_PROC \
 109 "ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                        "
 110 #define ZONE_HEADER_LWP \
 111 "ZONEID     NLWP  SWAP   RSS MEMORY      TIME  CPU ZONE                        "
 112 #define PSINFO_LINE \
 113 "%6d %-8s %5s %5s %-6s %3s  %3s %9s %3.3s%% %-.16s/%d"
 114 #define PSINFO_LINE_LGRP \
 115 "%6d %-8s %5s %5s %-6s %3s  %3s %9s %3.3s%% %4d %-.16s/%d"
 116 #define USAGE_LINE \
 117 "%6d %-8s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s "\
 118 "%3.3s %3.3s %-.12s/%d"
 119 #define USER_LINE \
 120 "%6d %-8s %5.5s %5.5s   %3.3s%% %9s %3.3s%%"
 121 #define TASK_LINE \
 122 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 123 #define PROJECT_LINE \
 124 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 125 #define ZONE_LINE \
 126 "%6d %8d %5s %5s   %3.3s%% %9s %3.3s%% %28s"
 127 
 128 #define TOTAL_LINE \
 129 "Total: %d processes, %d lwps, load averages: %3.2f, %3.2f, %3.2f"
 130 
 131 /* global variables */
 132 
 133 static char     *t_ulon;                        /* termcap: start underline */
 134 static char     *t_uloff;                       /* termcap: end underline */
 135 static char     *t_up;                          /* termcap: cursor 1 line up */
 136 static char     *t_eol;                         /* termcap: clear end of line */
 137 static char     *t_smcup;                       /* termcap: cursor mvcap on */
 138 static char     *t_rmcup;                       /* termcap: cursor mvcap off */


 343                  * If no match is found, prstat will use the size already
 344                  * gathered from psinfo.
 345                  */
 346         }
 347         free(results);
 348 }
 349 
 350 /*
 351  * A routine to display the contents of the list on the screen
 352  */
 353 static void
 354 list_print(list_t *list)
 355 {
 356         lwp_info_t *lwp;
 357         id_info_t *id;
 358         char usr[4], sys[4], trp[4], tfl[4];
 359         char dfl[4], lck[4], slp[4], lat[4];
 360         char vcx[4], icx[4], scl[4], sig[4];
 361         char psize[6], prssize[6], pmem[6], pcpu[6], ptime[12];
 362         char pstate[7], pnice[4], ppri[4];
 363         char pname[LOGNAME_MAX_ILLUMOS+1];
 364         char projname[PROJNAME_MAX+1];
 365         char zonename[ZONENAME_MAX+1];
 366         float cpu, mem;
 367         double loadavg[3] = {0, 0, 0};
 368         int i, lwpid;
 369 
 370         if (foreach_element(&set_tbl, &loadavg, psetloadavg) == 0) {
 371                 /*
 372                  * If processor sets aren't specified, we display system-wide
 373                  * load averages.
 374                  */
 375                 (void) getloadavg(loadavg, 3);
 376         }
 377 
 378         if (((opts.o_outpmode & OPT_UDATE) || (opts.o_outpmode & OPT_DDATE)) &&
 379             ((list->l_type == LT_LWPS) || !(opts.o_outpmode & OPT_SPLIT)))
 380                 print_timestamp();
 381         if (opts.o_outpmode & OPT_TTY)
 382                 (void) putchar('\r');
 383         (void) putp(t_ulon);


 435         (void) putchar('\n');
 436 
 437         for (i = 0; i < list->l_used; i++) {
 438                 switch (list->l_type) {
 439                 case LT_PROJECTS:
 440                 case LT_TASKS:
 441                 case LT_USERS:
 442                 case LT_ZONES:
 443                         id = list->l_ptrs[i];
 444                         /*
 445                          * CPU usage and memory usage normalization
 446                          */
 447                         if (total_cpu >= 100)
 448                                 cpu = (100 * id->id_pctcpu) / total_cpu;
 449                         else
 450                                 cpu = id->id_pctcpu;
 451                         if (id->id_sizematch == B_FALSE && total_mem >= 100)
 452                                 mem = (100 * id->id_pctmem) / total_mem;
 453                         else
 454                                 mem = id->id_pctmem;
 455                         if (list->l_type == LT_USERS) {
 456                                 pwd_getname(id->id_uid, pname, sizeof (pname),
 457                                     opts.o_outpmode & OPT_NORESOLVE,
 458                                     opts.o_outpmode & OPT_TERMCAP,
 459                                     LOGIN_WIDTH);
 460                         } else if (list->l_type == LT_ZONES) {
 461                                 getzonename(id->id_zoneid, zonename,
 462                                     sizeof (zonename) - 1,
 463                                     opts.o_outpmode & OPT_TERMCAP,
 464                                     ZONE_WIDTH);
 465                         } else {
 466                                 getprojname(id->id_projid, projname,
 467                                     sizeof (projname) - 1,
 468                                     opts.o_outpmode & OPT_NORESOLVE,
 469                                     opts.o_outpmode & OPT_TERMCAP,
 470                                     PROJECT_WIDTH);
 471                         }
 472                         Format_size(psize, id->id_size, 6);
 473                         Format_size(prssize, id->id_rssize, 6);
 474                         Format_pct(pmem, mem, 4);
 475                         Format_pct(pcpu, cpu, 4);
 476                         Format_time(ptime, id->id_time, 10);
 477                         if (opts.o_outpmode & OPT_TTY)
 478                                 (void) putchar('\r');
 479                         if (list->l_type == LT_PROJECTS)
 480                                 (void) printf(PROJECT_LINE, (int)id->id_projid,
 481                                     id->id_nproc, psize, prssize, pmem, ptime,
 482                                     pcpu, projname);
 483                         else if (list->l_type == LT_TASKS)
 484                                 (void) printf(TASK_LINE, (int)id->id_taskid,
 485                                     id->id_nproc, psize, prssize, pmem, ptime,
 486                                     pcpu, projname);
 487                         else if (list->l_type == LT_ZONES)
 488                                 (void) printf(ZONE_LINE, (int)id->id_zoneid,
 489                                     id->id_nproc, psize, prssize, pmem, ptime,
 490                                     pcpu, zonename);
 491                         else
 492                                 (void) printf(USER_LINE, id->id_nproc, pname,
 493                                     psize, prssize, pmem, ptime, pcpu);
 494                         (void) putp(t_eol);
 495                         (void) putchar('\n');
 496                         break;
 497                 case LT_LWPS:
 498                         lwp = list->l_ptrs[i];
 499                         if (opts.o_outpmode & OPT_LWPS)
 500                                 lwpid = lwp->li_info.pr_lwp.pr_lwpid;
 501                         else
 502                                 lwpid = lwp->li_info.pr_nlwp +
 503                                     lwp->li_info.pr_nzomb;
 504                         pwd_getname(lwp->li_info.pr_uid, pname, sizeof (pname),
 505                             opts.o_outpmode & OPT_NORESOLVE,
 506                             opts.o_outpmode & OPT_TERMCAP,
 507                             LOGIN_WIDTH);
 508                         if (opts.o_outpmode & OPT_PSINFO) {
 509                                 Format_size(psize, lwp->li_info.pr_size, 6);
 510                                 Format_size(prssize, lwp->li_info.pr_rssize, 6);
 511                                 Format_state(pstate,
 512                                     lwp->li_info.pr_lwp.pr_sname,
 513                                     lwp->li_info.pr_lwp.pr_onpro, 7);
 514                                 if (strcmp(lwp->li_info.pr_lwp.pr_clname,
 515                                     "RT") == 0 ||
 516                                     strcmp(lwp->li_info.pr_lwp.pr_clname,
 517                                     "SYS") == 0 ||
 518                                     lwp->li_info.pr_lwp.pr_sname == 'Z')
 519                                         (void) strcpy(pnice, "  -");
 520                                 else
 521                                         Format_num(pnice,
 522                                             lwp->li_info.pr_lwp.pr_nice - NZERO,
 523                                             4);
 524                                 Format_num(ppri, lwp->li_info.pr_lwp.pr_pri, 4);
 525                                 Format_pct(pcpu,
 526                                     FRC2PCT(lwp->li_info.pr_lwp.pr_pctcpu), 4);
 527                                 if (opts.o_outpmode & OPT_LWPS)
 528                                         Format_time(ptime,
 529                                             lwp->li_info.pr_lwp.pr_time.tv_sec,
 530                                             10);
 531                                 else
 532                                         Format_time(ptime,
 533                                             lwp->li_info.pr_time.tv_sec, 10);
 534                                 if (opts.o_outpmode & OPT_TTY)
 535                                         (void) putchar('\r');
 536                                 stripfname(lwp->li_info.pr_fname);
 537                                 if (opts.o_outpmode & OPT_LGRP) {
 538                                         (void) printf(PSINFO_LINE_LGRP,
 539                                             (int)lwp->li_info.pr_pid, pname,
 540                                             psize, prssize, pstate,
 541                                             ppri, pnice, ptime, pcpu,
 542                                             (int)lwp->li_info.pr_lwp.pr_lgrp,
 543                                             lwp->li_info.pr_fname, lwpid);
 544                                 } else {
 545                                         (void) printf(PSINFO_LINE,
 546                                             (int)lwp->li_info.pr_pid, pname,
 547                                             psize, prssize,
 548                                             pstate, ppri, pnice,
 549                                             ptime, pcpu,
 550                                             lwp->li_info.pr_fname, lwpid);
 551                                 }
 552                                 (void) putp(t_eol);
 553                                 (void) putchar('\n');
 554                         }
 555                         if (opts.o_outpmode & OPT_MSACCT) {
 556                                 Format_pct(usr, lwp->li_usr, 4);
 557                                 Format_pct(sys, lwp->li_sys, 4);
 558                                 Format_pct(slp, lwp->li_slp, 4);
 559                                 Format_num(vcx, lwp->li_vcx, 4);
 560                                 Format_num(icx, lwp->li_icx, 4);
 561                                 Format_num(scl, lwp->li_scl, 4);
 562                                 Format_num(sig, lwp->li_sig, 4);
 563                                 Format_pct(trp, lwp->li_trp, 4);
 564                                 Format_pct(tfl, lwp->li_tfl, 4);
 565                                 Format_pct(dfl, lwp->li_dfl, 4);
 566                                 Format_pct(lck, lwp->li_lck, 4);
 567                                 Format_pct(lat, lwp->li_lat, 4);
 568                                 if (opts.o_outpmode & OPT_TTY)