From 17e0eaf0f3aa628c7e43d7f11b68dfabeef5918a Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 1 Jul 2012 00:00:22 -0500 Subject: [PATCH] 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 --- top/top.c | 12 +++++++++--- top/top.h | 1 + top/top_nls.c | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/top/top.c b/top/top.c index bfe57276..c0bd22f2 100644 --- a/top/top.c +++ b/top/top.c @@ -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); diff --git a/top/top.h b/top/top.h index d45f0038..d7d2754e 100644 --- a/top/top.h +++ b/top/top.h @@ -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 diff --git a/top/top_nls.c b/top/top_nls.c index b533674d..fbd5899c 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -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"); }