ps: exploits <pids> enhancement for control group name

[ 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 3a00c7e499
commit cfd47f710a
3 changed files with 10 additions and 18 deletions

View File

@ -72,6 +72,7 @@ makEXT(ADDR_KSTK_ESP)
makEXT(ADDR_START_CODE) makEXT(ADDR_START_CODE)
makEXT(ADDR_START_STACK) makEXT(ADDR_START_STACK)
makEXT(ALARM) makEXT(ALARM)
makEXT(CGNAME)
makEXT(CGROUP) makEXT(CGROUP)
makEXT(CMD) makEXT(CMD)
makEXT(CMDLINE) makEXT(CMDLINE)

View File

@ -62,6 +62,7 @@ makREL(ADDR_KSTK_ESP)
makREL(ADDR_START_CODE) makREL(ADDR_START_CODE)
makREL(ADDR_START_STACK) makREL(ADDR_START_STACK)
makREL(ALARM) makREL(ALARM)
makREL(CGNAME)
makREL(CGROUP) makREL(CGROUP)
makREL(CMD) makREL(CMD)
makREL(CMDLINE) makREL(CMDLINE)

View File

@ -314,6 +314,13 @@ setREL3(CMD,CMDLINE,ENVIRON)
} }
static int pr_cgname(char *restrict const outbuf,const proc_t *restrict const pp) {
int rightward = max_rightward;
setREL1(CGNAME)
escaped_copy(outbuf, rSv(CGNAME, str, pp), OUTBUF_SIZE, &rightward);
return max_rightward-rightward;
}
static int pr_cgroup(char *restrict const outbuf,const proc_t *restrict const pp) { static int pr_cgroup(char *restrict const outbuf,const proc_t *restrict const pp) {
int rightward = max_rightward; int rightward = max_rightward;
setREL1(CGROUP) setREL1(CGROUP)
@ -321,23 +328,6 @@ setREL1(CGROUP)
return max_rightward-rightward; return max_rightward-rightward;
} }
static int pr_cgname(char *restrict const outbuf,const proc_t *restrict const pp) {
int rightward = max_rightward;
int i;
char *name;
setREL1(CGROUP)
if ((name = strstr(rSv(CGROUP, str, pp), ":name=")) != NULL) {
name += 6;
if (name != '\0') {
escape_str(outbuf, name, OUTBUF_SIZE, &rightward);
return max_rightward - rightward;
}
}
/* fallback: use full cgroup for name */
return pr_cgroup(outbuf, pp);
}
/* Non-standard, from SunOS 5 */ /* Non-standard, from SunOS 5 */
static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){ static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){
char *endp = outbuf; char *endp = outbuf;
@ -1408,7 +1398,7 @@ static const format_struct format_array[] = { /*
{"bsdtime", "TIME", pr_bsdtime, PROCPS_PIDS_TICS_ALL, 6, LNX, ET|RIGHT}, {"bsdtime", "TIME", pr_bsdtime, PROCPS_PIDS_TICS_ALL, 6, LNX, ET|RIGHT},
{"c", "C", pr_c, PROCPS_PIDS_extra, 2, SUN, ET|RIGHT}, {"c", "C", pr_c, PROCPS_PIDS_extra, 2, SUN, ET|RIGHT},
{"caught", "CAUGHT", pr_sigcatch, PROCPS_PIDS_SIGCATCH, 9, BSD, TO|SIGNAL}, /*sigcatch*/ {"caught", "CAUGHT", pr_sigcatch, PROCPS_PIDS_SIGCATCH, 9, BSD, TO|SIGNAL}, /*sigcatch*/
{"cgname", "CGNAME", pr_cgname, PROCPS_PIDS_CGROUP, 27, LNX, PO|UNLIMITED}, {"cgname", "CGNAME", pr_cgname, PROCPS_PIDS_CGNAME, 27, LNX, PO|UNLIMITED},
{"cgroup", "CGROUP", pr_cgroup, PROCPS_PIDS_CGROUP, 27, LNX, PO|UNLIMITED}, {"cgroup", "CGROUP", pr_cgroup, PROCPS_PIDS_CGROUP, 27, LNX, PO|UNLIMITED},
{"class", "CLS", pr_class, PROCPS_PIDS_SCHED_CLASS, 3, XXX, TO|LEFT}, {"class", "CLS", pr_class, PROCPS_PIDS_SCHED_CLASS, 3, XXX, TO|LEFT},
{"cls", "CLS", pr_class, PROCPS_PIDS_SCHED_CLASS, 3, HPU, TO|RIGHT}, /*says HPUX or RT*/ {"cls", "CLS", pr_class, PROCPS_PIDS_SCHED_CLASS, 3, HPU, TO|RIGHT}, /*says HPUX or RT*/