library: added PROCPS_PIDS_CGNAME for <pids> interface

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>
This commit is contained in:
Jim Warner 2015-10-12 00:00:00 -05:00 committed by Craig Small
parent d53e98ff97
commit a59a269661
2 changed files with 3 additions and 0 deletions

View 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 },

View 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