Skip to content

Commit 702cf08

Browse files
committed
core/execute: warn when threaded mode is detected
Prompted by systemd#22486.
1 parent 084e770 commit 702cf08

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/core/execute.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,6 +4250,12 @@ static int exec_child(
42504250
}
42514251

42524252
r = cg_attach_everywhere(params->cgroup_supported, p, 0, NULL, NULL);
4253+
if (r == -EUCLEAN) {
4254+
*exit_status = EXIT_CGROUP;
4255+
return log_unit_error_errno(unit, r, "Failed to attach process to cgroup %s "
4256+
"because the cgroup or one of its parents or "
4257+
"siblings is in the threaded mode: %m", p);
4258+
}
42534259
if (r < 0) {
42544260
*exit_status = EXIT_CGROUP;
42554261
return log_unit_error_errno(unit, r, "Failed to attach to cgroup %s: %m", p);

src/shared/cgroup-setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ int cg_attach(const char *controller, const char *path, pid_t pid) {
346346
xsprintf(c, PID_FMT "\n", pid);
347347

348348
r = write_string_file(fs, c, WRITE_STRING_FILE_DISABLE_BUFFER);
349+
if (r == -EOPNOTSUPP && cg_is_threaded(controller, path) > 0)
350+
/* When the threaded mode is used, we cannot read/write the file. Let's return recognizable error. */
351+
return -EUCLEAN;
349352
if (r < 0)
350353
return r;
351354

0 commit comments

Comments
 (0)