top: add new scrollable column ENVIRON

The recent introduction of scrollable variable width
columns makes a process 'environment' a potentially
useful addition to top's displayable fields.

This commit exploits the following new library flag:
   PROC_EDITENVRCVT

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2012-07-01 00:00:22 -05:00 committed by Craig Small
parent 348e6091cb
commit 17e0eaf0f3
3 changed files with 13 additions and 3 deletions

View File

@ -208,6 +208,7 @@ SCB_NUMx(CPN, processor)
SCB_NUM1(CPU, pcpu)
SCB_NUM1(DAT, drs)
SCB_NUM1(DRT, dt)
SCB_STRS(ENV, environ[0])
SCB_NUM1(FLG, flags)
SCB_NUM1(FL1, maj_flt)
SCB_NUM1(FL2, min_flt)
@ -1214,6 +1215,7 @@ static inline int user_matched (WIN_t *q, const proc_t *p) {
#define L_status PROC_FILLSTATUS
#define L_CGROUP PROC_EDITCGRPCVT | PROC_FILLCGROUP
#define L_CMDLINE PROC_EDITCMDLCVT | PROC_FILLARG
#define L_ENVIRON PROC_EDITENVRCVT | PROC_FILLENV
#define L_EUSER PROC_FILLUSR
#define L_OUSER PROC_FILLSTATUS | PROC_FILLUSR
#define L_EGROUP PROC_FILLSTATUS | PROC_FILLGRP
@ -1291,13 +1293,14 @@ static FLD_t Fieldstab[] = {
{ "CGROUPS ", NULL, -1, -1, SF(CGR), L_CGROUP, NULL },
{ "SUPGIDS ", NULL, -1, -1, SF(SGD), L_status, NULL },
{ "SUPGRPS ", NULL, -1, -1, SF(SGN), L_SUPGRP, NULL },
{ NULL, NULL, -1, -1, SF(TGD), L_status, NULL }
{ NULL, NULL, -1, -1, SF(TGD), L_status, NULL },
#ifdef OOMEM_ENABLE
#define L_oom PROC_FILLOOM
,{ "Adj ", "%3d ", -1, -1, SF(OOA), L_oom, NULL }
,{ " Badness ", "%8d ", -1, -1, SF(OOM), L_oom, NULL }
{ "Adj ", "%3d ", -1, -1, SF(OOA), L_oom, NULL },
{ " Badness ", "%8d ", -1, -1, SF(OOM), L_oom, NULL },
#undef L_oom
#endif
{ "ENVIRON ", NULL, -1, -1, SF(ENV), L_ENVIRON, NULL }
#undef SF
};
@ -3699,6 +3702,9 @@ static void task_show (const WIN_t *q, const proc_t *p, char *ptr) {
case P_DRT:
makeCOL(scale_num((unsigned long)p->dt, w, s));
break;
case P_ENV:
makeVAR(*p->environ);
break;
case P_FLG:
{ char tmp[SMLBUFSIZ];
snprintf(tmp, sizeof(tmp), f, (long)p->flags);

View File

@ -166,6 +166,7 @@ enum pflag {
#ifdef OOMEM_ENABLE
P_OOA, P_OOM,
#endif
P_ENV,
#ifdef USE_X_COLHDR
// not really pflags, used with tbl indexing
P_MAXPFLGS

View File

@ -147,6 +147,9 @@ static void build_desc_nlstab (void) {
Desc_nlstab[P_OOA] = _("oom_adjustment (2^X)");
Desc_nlstab[P_OOM] = _("oom_score (badness)");
#endif
/* Translation Hint: The abbreviation 'vars' below is shorthand for
'variables' */
Desc_nlstab[P_ENV] = _("Environment vars");
}