library: standardize handling of cgroup, supgid
Some inconsistencies have emerged during development
of support for these relatively new proc_t fields.
For example, a PROC_FILLCGROUP flag (via file2strvec)
could return NULL in cgroup whereas PROC_EDITCGRPCVT
(via fill_cgroup_cvt) *almost* guaranteed a return
address (as is true for PROC_EDITCMDLCVT and cmdline).
But even PROC_EDITCGRPCVT could return NULL if the
kernel version was less than 2.6.24. Then with NULL
ps would display a "-" while top would show "n/a".
And while unlikely, with the PROC_FILLSTATUS flag (via
status2proc) a NULL supgid address was theoretically
possible and both ps and top would then show "n/a".
This commit standardizes the following usage:
. PROC_FILLSTATUS (via status2proc)
guarantees a valid supgid address
representing either a true comma
delimited list or "-"
. PROC_FILLCGROUP plus
PROC_EDITCGRPCVT (via fill_cgroup_cvt)
guarantees a cgroup single vector
representing either a true control
group hierarchy or "-"
And as was true before, the following remains true:
PROC_FILLCOM or
PROC_FILLARG (via file2strvec)
may return a NULL cmdline pointer
. PROC_FILLCGROUP (via file2strvec)
may return a NULL cgroup pointer
. PROC_FILLCOM or
PROC_FILLARG plus
PROC_EDITCMDLCVT (via fill_cmdline_cvt)
guarantees a cmdline single vector
representing either a true command
line or a bracketed program name
. PROC_FILLSTATUS plus
PROC_FILLSUPGRP (via supgrps_from_supgids)
guarantees a valid supgrp address
representing either a true comma
delimited list or "-"
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@@ -362,8 +362,7 @@ ENTER(0x220);
|
|||||||
for ( ; j; j--)
|
for ( ; j; j--)
|
||||||
if (' ' == P->supgid[j])
|
if (' ' == P->supgid[j])
|
||||||
P->supgid[j] = ',';
|
P->supgid[j] = ',';
|
||||||
} else
|
}
|
||||||
P->supgid = xstrdup("-");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case_CapBnd:
|
case_CapBnd:
|
||||||
@@ -412,6 +411,9 @@ ENTER(0x220);
|
|||||||
P->tid = Pid;
|
P->tid = Pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!P->supgid)
|
||||||
|
P->supgid = xstrdup("-");
|
||||||
|
|
||||||
LEAVE(0x220);
|
LEAVE(0x220);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,8 +795,7 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
|
|||||||
} else
|
} else
|
||||||
p->cmdline = NULL;
|
p->cmdline = NULL;
|
||||||
|
|
||||||
if ((flags & PROC_FILLCGROUP) // read /proc/#/cgroup
|
if ((flags & PROC_FILLCGROUP)) { // read /proc/#/cgroup
|
||||||
&& linux_version_code >= LINUX_VERSION(2,6,24)) {
|
|
||||||
if (flags & PROC_EDITCGRPCVT)
|
if (flags & PROC_EDITCGRPCVT)
|
||||||
fill_cgroup_cvt(path, p);
|
fill_cgroup_cvt(path, p);
|
||||||
else
|
else
|
||||||
@@ -903,8 +904,7 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric
|
|||||||
} else
|
} else
|
||||||
t->cmdline = NULL;
|
t->cmdline = NULL;
|
||||||
|
|
||||||
if ((flags & PROC_FILLCGROUP) // read /proc/#/task/#/cgroup
|
if ((flags & PROC_FILLCGROUP)) { // read /proc/#/task/#/cgroup
|
||||||
&& linux_version_code >= LINUX_VERSION(2,6,24)) {
|
|
||||||
if (flags & PROC_EDITCGRPCVT)
|
if (flags & PROC_EDITCGRPCVT)
|
||||||
fill_cgroup_cvt(path, t);
|
fill_cgroup_cvt(path, t);
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user