* [PATCH] selftests/cgroup: Decode waitid results correctly in clone_reap
@ 2026-11-11 15:30 Kanishk Singh
2026-11-11 17:06 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Kanishk Singh @ 2026-11-11 15:30 UTC (permalink / raw)
To: Tejun Heo
Cc: Johannes Weiner, Michal Koutný,
Shuah Khan, cgroups, linux-kselftest, linux-kernel
clone_reap() applies the waitpid() status macros to waitid()'s
si_status. Unlike waitpid()'s encoded status, si_status already holds
the exit code or signal number, and si_code identifies the event.
For example, a child exiting with status 128 is reported as successful,
while a child exiting with status 42 produces -1 rather than 42. Stop
and continuation events are also rejected. With WNOHANG, a live child
can be reported as having exited successfully because the zeroed
si_status passes WIFEXITED().
Check si_code for the requested event and return si_status directly
for exit and stop events. Accept CLD_TRAPPED along with CLD_STOPPED,
as both correspond to stopped children.
Fixes: 27eaaaf3b30e ("selftests/cgroup: add tests for cloning into cgroups")
Signed-off-by: Kanishk Singh <kanishk2607@gmail.com>
---
This patch was prepared with ChatGPT/Codex assistance for code inspection,
implementation, commit-message drafting, and local testing. The task was to
find and reproduce a cgroup selftest helper bug, make a focused fix, and
verify the result against the original helper.
Testing: the cgroup selftest programs build successfully. A standalone
reproducer linked against cgroup_util.c passes all 256 exit codes, SIGSTOP,
SIGCONT, SIGKILL, WNOHANG, ECHILD, and an interrupted wait after this change.
The original helper fails 255 of the 256 exit-code comparisons, the stop
and continuation checks, the WNOHANG check, and the interrupted-wait
exit-code check. No full cgroup runtime suite was run: the environment has
no cgroup mount. A ptrace stop check was skipped because PTRACE_TRACEME
was unavailable.
tools/testing/selftests/cgroup/lib/cgroup_util.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/cgroup/lib/cgroup_util.c
b/tools/testing/selftests/cgroup/lib/cgroup_util.c
index 823b0312b..4915d80ed 100644
--- a/tools/testing/selftests/cgroup/lib/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/lib/cgroup_util.c
@@ -508,17 +508,17 @@ int clone_reap(pid_t pid, int options)
}
if (options & WEXITED) {
- if (WIFEXITED(info.si_status))
- return WEXITSTATUS(info.si_status);
+ if (info.si_code == CLD_EXITED)
+ return info.si_status;
}
if (options & WSTOPPED) {
- if (WIFSTOPPED(info.si_status))
- return WSTOPSIG(info.si_status);
+ if (info.si_code == CLD_STOPPED || info.si_code == CLD_TRAPPED)
+ return info.si_status;
}
if (options & WCONTINUED) {
- if (WIFCONTINUED(info.si_status))
+ if (info.si_code == CLD_CONTINUED)
return 0;
}
base-commit: 067c5c24cef23d913b67eaaf71ae67e7169a6620
--
2.52.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/cgroup: Decode waitid results correctly in clone_reap
2026-11-11 15:30 [PATCH] selftests/cgroup: Decode waitid results correctly in clone_reap Kanishk Singh
@ 2026-11-11 17:06 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-11-11 17:06 UTC (permalink / raw)
To: Kanishk Singh
Cc: Johannes Weiner, Michal Koutný,
Shuah Khan, cgroups, linux-kselftest, linux-kernel
Applied to cgroup/for-7.5 with the Fixes tag dropped.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-11 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 15:30 [PATCH] selftests/cgroup: Decode waitid results correctly in clone_reap Kanishk Singh
2026-11-11 17:06 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®