[LTP] [PATCH 1/2] pids: fix cleanup of orphaned pids_task1 children

Andrea Cervesato andrea.cervesato@suse.de
Mon Jun 15 16:16:29 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

pids_task1 forks a child that calls pause(), then the parent exits.
The orphaned child remains in the cgroup but gets reparented to init,
so it is not a child of the test shell.

stop_pids_tasks_path() reads cgroup.procs which includes this orphan.
kill -9 succeeds but wait fails with 'not a child of this shell'.
Using ROD for kill also unnecessarily aborts if the process is already
dead.

Fix by suppressing errors from both kill and wait, and add killall
for pids_task1 in cleanup() to catch any remaining orphans.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/controllers/pids/pids.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/controllers/pids/pids.sh b/testcases/kernel/controllers/pids/pids.sh
index 26a0c6a221ea63e683016ebfea33f2744800aaea..dd27b5616f0c4b55c625ca57efa2507325949b07 100755
--- a/testcases/kernel/controllers/pids/pids.sh
+++ b/testcases/kernel/controllers/pids/pids.sh
@@ -35,6 +35,7 @@ EOF
 cleanup()
 {
 	killall -9 pids_task2 >/dev/null 2>&1
+	killall -9 pids_task1 >/dev/null 2>&1
 
 	cgroup_cleanup
 }
@@ -79,8 +80,8 @@ stop_pids_tasks_path()
 	path=$1
 
 	for i in $(cat "$path/$task_list"); do
-		ROD kill -9 $i
-		wait $i
+		kill -9 $i 2>/dev/null
+		wait $i 2>/dev/null
 	done
 }
 

-- 
2.51.0



More information about the ltp mailing list