top(1): Display of TID when using 'H' flag

Some users prefer seeing the TID when viewing individual threads. This
makes sense as the PID will be the same for multiple entries. An attempt
was made to include both, but there is insufficient room. As such, using
the TID.

While here, rename the header variables to be more understandable.

Discussed with:	mmacy
Reported on:	2009-10-07
This commit is contained in:
eadler 2018-06-01 05:51:40 +00:00
parent a31c3b9418
commit e1ba86c936
2 changed files with 10 additions and 9 deletions

View File

@ -97,18 +97,18 @@ static char io_header[] =
#define io_Proc_format \
"%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s"
static char smp_header_thr[] =
static char smp_header_thr_and_pid[] =
" PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
static char smp_header[] =
" PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
static char smp_header_tid_only[] =
" THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE C TIME %7s COMMAND";
#define smp_Proc_format \
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s %2d%7s %6.2f%% %.*s"
static char up_header_thr[] =
static char up_header_thr_and_pid[] =
" PID%*s %-*.*s THR PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
static char up_header[] =
" PID%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
static char up_header_tid_only[] =
" THR%*s %-*.*s " "PRI NICE SIZE RES%*s STATE TIME %7s COMMAND";
#define up_Proc_format \
"%5d%*s %-*.*s %s%3d %4s%7s %6s%*.*s %-6.6s%.0d%7s %6.2f%% %.*s"
@ -436,8 +436,8 @@ format_header(char *uname_field)
* separate lines).
*/
prehead = smpmode ?
(ps.thread ? smp_header : smp_header_thr) :
(ps.thread ? up_header : up_header_thr);
(ps.thread ? smp_header_tid_only : smp_header_thr_and_pid) :
(ps.thread ? up_header_tid_only : up_header_thr_and_pid);
snprintf(Header, sizeof(Header), prehead,
jidlength, ps.jail ? " JID" : "",
namelength, namelength, uname_field,
@ -1145,7 +1145,7 @@ format_next_process(caddr_t xhandle, char *(*get_userid)(int), int flags)
(int)(sizeof(thr_buf) - 2), pp->ki_numthreads);
snprintf(fmt, sizeof(fmt), proc_fmt,
pp->ki_pid,
(ps.thread) ? pp->ki_tid : pp->ki_pid,
jidlength, jid_buf,
namelength, namelength, (*get_userid)(pp->ki_ruid),
thr_buf,

View File

@ -331,6 +331,7 @@ command.
.TP
.B H
Toggle the display of threads.
Also toggles the display of PID or TID.
.TP
.B i
(or