cgroup-util: allow cg_read_pid() to skip unmapped (zero) pids

This commit is contained in:
Timo Rothenpieler
2024-05-14 16:12:20 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 19614a08d1
commit 00f1714311
7 changed files with 49 additions and 33 deletions
+4 -2
View File
@@ -3627,7 +3627,9 @@ int unit_search_main_pid(Unit *u, PidRef *ret) {
for (;;) {
_cleanup_(pidref_done) PidRef npidref = PIDREF_NULL;
r = cg_read_pidref(f, &npidref);
/* cg_read_pidref() will return an error on unmapped PIDs.
* We can't reasonably deal with units that contain those. */
r = cg_read_pidref(f, &npidref, CGROUP_DONT_SKIP_UNMAPPED);
if (r < 0)
return r;
if (r == 0)
@@ -3669,7 +3671,7 @@ static int unit_watch_pids_in_path(Unit *u, const char *path) {
for (;;) {
_cleanup_(pidref_done) PidRef pid = PIDREF_NULL;
r = cg_read_pidref(f, &pid);
r = cg_read_pidref(f, &pid, /* flags = */ 0);
if (r == 0)
break;
if (r < 0) {
+1 -1
View File
@@ -1300,7 +1300,7 @@ static int append_cgroup(sd_bus_message *reply, const char *p, Set *pids) {
* threaded domain cgroup contains the PIDs of all processes in the subtree and is not
* readable in the subtree proper. */
r = cg_read_pidref(f, &pidref);
r = cg_read_pidref(f, &pidref, /* flags = */ 0);
if (IN_SET(r, 0, -EOPNOTSUPP))
break;
if (r < 0)