All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Cervesato <andrea.cervesato@suse.de>
To: Linux Test Project <ltp@lists.linux.it>
Subject: [LTP] [PATCH v2 1/2] pids: fix cleanup of orphaned pids_task1 children
Date: Tue, 16 Jun 2026 10:30:06 +0200	[thread overview]
Message-ID: <20260616-fix_pids_errors-v2-1-a1e1d377f8b7@suse.com> (raw)
In-Reply-To: <20260616-fix_pids_errors-v2-0-a1e1d377f8b7@suse.com>

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.

Reviewed-by: Li Wang <li.wang@linux.dev>
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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2026-06-16  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-16  8:30 [LTP] [PATCH v2 0/2] Fix sporadic failures in pids shell tests Andrea Cervesato
2026-06-16  8:30 ` Andrea Cervesato [this message]
2026-06-16 10:10   ` [LTP] pids: fix cleanup of orphaned pids_task1 children linuxtestproject.agent
2026-06-16  8:30 ` [LTP] [PATCH v2 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() Andrea Cervesato
2026-06-16 12:13   ` Li Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260616-fix_pids_errors-v2-1-a1e1d377f8b7@suse.com \
    --to=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.