]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/execute: warn when threaded mode is detected 22498/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 13 Feb 2022 11:52:53 +0000 (20:52 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 16 Feb 2022 06:59:03 +0000 (15:59 +0900)
Prompted by #22486.

src/core/execute.c
src/shared/cgroup-setup.c

index 380755eb09b186de4c57cf0176d3501212290d02..72f3534908a9a64a1f809ababe187fcd9bde9334 100644 (file)
@@ -4250,6 +4250,12 @@ static int exec_child(
                 }
 
                 r = cg_attach_everywhere(params->cgroup_supported, p, 0, NULL, NULL);
+                if (r == -EUCLEAN) {
+                        *exit_status = EXIT_CGROUP;
+                        return log_unit_error_errno(unit, r, "Failed to attach process to cgroup %s "
+                                                    "because the cgroup or one of its parents or "
+                                                    "siblings is in the threaded mode: %m", p);
+                }
                 if (r < 0) {
                         *exit_status = EXIT_CGROUP;
                         return log_unit_error_errno(unit, r, "Failed to attach to cgroup %s: %m", p);
index 8bda66ca36a5fd3aa6bc82cd683de12c4221b091..38a6755d178ce54a83624b4d5ce7ea5d8d29b346 100644 (file)
@@ -346,6 +346,9 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
         xsprintf(c, PID_FMT "\n", pid);
 
         r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER);
+        if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0)
+                /* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
+                return -EUCLEAN;
         if (r < 0)
                 return r;