summaryrefslogtreecommitdiffstats
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:25:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-16 18:25:59 +0000
commit1e34d75027c0773e21b35688c27034d5af5e635c (patch)
tree7f3e33142d7a4d06037846454f08b1b0350b2a95 /src/basic/cgroup-util.c
parentAdding upstream version 256.4. (diff)
downloadsystemd-1e34d75027c0773e21b35688c27034d5af5e635c.tar.xz
systemd-1e34d75027c0773e21b35688c27034d5af5e635c.zip
Adding upstream version 256.5.upstream/256.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r--src/basic/cgroup-util.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 553ee60..b0fe0ec 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -149,7 +149,9 @@ int cg_read_pidref(FILE *f, PidRef *ret, CGroupFlags flags) {
if (pid == 0)
return -EREMOTE;
- if (FLAGS_SET(flags, CGROUP_NO_PIDFD)) {
+ /* We might read kernel thread pids from cgroup.procs for which we cannot create a pidfd so
+ * catch those and don't try to create a pidfd for them. */
+ if (FLAGS_SET(flags, CGROUP_NO_PIDFD) || pid_is_kernel_thread(pid) > 0) {
*ret = PIDREF_MAKE_FROM_PID(pid);
return 1;
}
@@ -369,6 +371,12 @@ static int cg_kill_items(
if (set_get(s, PID_TO_PTR(pidref.pid)) == PID_TO_PTR(pidref.pid))
continue;
+ /* Ignore kernel threads to mimick the behavior of cgroup.kill. */
+ if (pidref_is_kernel_thread(&pidref) > 0) {
+ log_debug("Ignoring kernel thread with pid " PID_FMT " in cgroup '%s'", pidref.pid, path);
+ continue;
+ }
+
if (log_kill)
ret_log_kill = log_kill(&pidref, sig, userdata);