From a59a269661f495094785ca12f4f9b71de513335d Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 12 Oct 2015 00:00:00 -0500 Subject: [PATCH] library: added PROCPS_PIDS_CGNAME for 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 --- proc/pids.c | 2 ++ proc/pids.h | 1 + 2 files changed, 3 insertions(+) diff --git a/proc/pids.c b/proc/pids.c index 8956c323..62ac2937 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -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 }, diff --git a/proc/pids.h b/proc/pids.h index e6c30725..f32e1031 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -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