]> granicus.if.org Git - procps-ng/commitdiff
library: added PROCPS_PIDS_CGNAME for <pids> interface
authorJim Warner <james.warner@comcast.net>
Mon, 12 Oct 2015 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 14 Oct 2015 10:48:41 +0000 (21:48 +1100)
The ps program was modified to print the control group
names, based on the library provided list of all those
control groups to which a process belongs. But this is
probably something the newlib should be doing for all.

So this commit borrows the ps approach to cg names and
thus will make that available to all future consumers.

[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/pids.c
proc/pids.h

index 8956c323cc3183ee5c2cc5a67d579ca4a49c5413..62ac2937f698d57cb52b2f972fd23e1e27e64211 100644 (file)
@@ -128,6 +128,7 @@ REG_set(ADDR_KSTK_ESP,    ul_int,  kstk_esp)
 REG_set(ADDR_START_CODE,  ul_int,  start_code)
 REG_set(ADDR_START_STACK, ul_int,  start_stack)
 REG_set(ALARM,            sl_int,  alarm)
+setDECL(CGNAME)       { char *name = strstr(*P->cgroup, ":name="); if (name && *(name+6)) name += 6; else name = *P->cgroup; R->result.str = strdup(name); }
 STV_set(CGROUP,                    cgroup)
 VEC_set(CGROUP_V,                  cgroup)
 STR_set(CMD,                       cmd)
@@ -378,6 +379,7 @@ static struct {
     { RS(ADDR_START_CODE),   f_stat,     NULL,      QS(ul_int),   0       },
     { RS(ADDR_START_STACK),  f_stat,     NULL,      QS(ul_int),   0       },
     { RS(ALARM),             f_stat,     NULL,      QS(sl_int),   0       },
+    { RS(CGNAME),            x_cgroup,   FF(str),   QS(str),      0       },
     { RS(CGROUP),            x_cgroup,   FF(str),   QS(str),      0       },
     { RS(CGROUP_V),          v_cgroup,   FF(strv),  QS(strv),     0       },
     { RS(CMD),               f_either,   FF(str),   QS(str),      0       },
index e6c30725ea224d78643ad5c607f80a8d9618728f..f32e1031ca752efcd3f7772b91d7c77990612b27 100644 (file)
@@ -32,6 +32,7 @@ enum pids_item {
     PROCPS_PIDS_ADDR_START_CODE,       // ul_int
     PROCPS_PIDS_ADDR_START_STACK,      // ul_int
     PROCPS_PIDS_ALARM,                 // sl_int
+    PROCPS_PIDS_CGNAME,                // str
     PROCPS_PIDS_CGROUP,                // str
     PROCPS_PIDS_CGROUP_V,              // strv
     PROCPS_PIDS_CMD,                   // str