ps: display control group name
The cgroup field while shown as a vector is a concatenated
string, so alot of the complexity of sorting and displaying
has gone.
This change simplifies the cgroup sorting and adds display
and sorting for the name attribute of the cgroup, if found.
Signed-off-by: Craig Small <csmall@enc.com.au>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 0ee090ae16
This commit is contained in:
19
ps/output.c
19
ps/output.c
@ -313,6 +313,7 @@ setREL3(CMD,CMDLINE,ENVIRON)
|
||||
return max_rightward-rightward;
|
||||
}
|
||||
|
||||
|
||||
static int pr_cgroup(char *restrict const outbuf,const proc_t *restrict const pp) {
|
||||
int rightward = max_rightward;
|
||||
setREL1(CGROUP)
|
||||
@ -320,6 +321,23 @@ setREL1(CGROUP)
|
||||
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 */
|
||||
static int pr_fname(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||
char *endp = outbuf;
|
||||
@ -1390,6 +1408,7 @@ static const format_struct format_array[] = { /*
|
||||
{"bsdtime", "TIME", pr_bsdtime, PROCPS_PIDS_TICS_ALL, 6, LNX, 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*/
|
||||
{"cgname", "CGNAME", pr_cgname, 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},
|
||||
{"cls", "CLS", pr_class, PROCPS_PIDS_SCHED_CLASS, 3, HPU, TO|RIGHT}, /*says HPUX or RT*/
|
||||
|
Reference in New Issue
Block a user