ps: sort by cgroup
A rather small fix to sort by cgroup. This sorting function could be used for other string vector entries, but I can't see why you want to for, say, environment. Reference: https://bugs.debian.org/692279 Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
e3d9ee04d9
commit
4bd0e539af
1
NEWS
1
NEWS
@ -1,5 +1,6 @@
|
||||
procps-ng-NEXT
|
||||
----------------
|
||||
* ps: sort by cgroup Debian #692279
|
||||
|
||||
procps-ng-3.3.11
|
||||
----------------
|
||||
|
14
ps/output.c
14
ps/output.c
@ -96,6 +96,18 @@ static int sr_nop(const proc_t* a, const proc_t* b){
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sr_cgroup(const proc_t* a, const proc_t* b)
|
||||
{
|
||||
int i;
|
||||
int cmpval;
|
||||
for (i=0; a->cgroup[i] != NULL && b->cgroup[i] != NULL; i++) {
|
||||
if ((cmpval = strcmp(a->cgroup[i], b->cgroup[i])) != 0)
|
||||
return cmpval;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#define CMP_STR(NAME) \
|
||||
static int sr_ ## NAME(const proc_t* P, const proc_t* Q) { \
|
||||
return strcmp(P->NAME, Q->NAME); \
|
||||
@ -1439,7 +1451,7 @@ static const format_struct format_array[] = {
|
||||
{"bsdtime", "TIME", pr_bsdtime, sr_nop, 6, 0, LNX, ET|RIGHT},
|
||||
{"c", "C", pr_c, sr_pcpu, 2, 0, SUN, ET|RIGHT},
|
||||
{"caught", "CAUGHT", pr_sigcatch, sr_nop, 9, 0, BSD, TO|SIGNAL}, /*sigcatch*/
|
||||
{"cgroup", "CGROUP", pr_cgroup, sr_nop, 27,CGRP, LNX, PO|UNLIMITED},
|
||||
{"cgroup", "CGROUP", pr_cgroup, sr_cgroup, 27,CGRP, LNX, PO|UNLIMITED},
|
||||
{"class", "CLS", pr_class, sr_sched, 3, 0, XXX, TO|LEFT},
|
||||
{"cls", "CLS", pr_class, sr_sched, 3, 0, HPU, TO|RIGHT}, /*says HPUX or RT*/
|
||||
{"cmaj_flt", "-", pr_nop, sr_cmaj_flt, 1, 0, LNX, AN|RIGHT},
|
||||
|
Loading…
Reference in New Issue
Block a user