diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-07-30 11:53:32 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-07-30 11:53:32 +0200 |
commit | 0fbb569de1dcc06118dba006cf7a40caf6cd94d0 (patch) | |
tree | 66aa4f75fddb0a35d651ecc19a6faf1f15cb4cc0 /src/basic | |
parent | kernel-install: Try some more initrd variants in 90-loaderentry.install (diff) | |
download | systemd-0fbb569de1dcc06118dba006cf7a40caf6cd94d0.tar.xz systemd-0fbb569de1dcc06118dba006cf7a40caf6cd94d0.zip |
cgroup-util: Ignore kernel threads in cg_kill_items()
Similar to the implementation of cgroup.kill in the kernel, let's
skip kernel threads in cg_kill_items() as trying to kill kernel
threads as an unprivileged process will fail with EPERM and doesn't
do anything when running privileged.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/cgroup-util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 65fbd09159..c2150c00c6 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -369,6 +369,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); |