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 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain()
Date: Mon, 15 Jun 2026 16:16:30 +0200	[thread overview]
Message-ID: <20260615-fix_pids_errors-v1-2-99a54a205180@suse.com> (raw)
In-Reply-To: <20260615-fix_pids_errors-v1-0-99a54a205180@suse.com>

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

A process can die between reading cgroup.procs and writing its PID
to the destination cgroup. When this happens, the kernel returns
ESRCH which is a normal race condition, not a test infrastructure
failure.

Skip ESRCH errors instead of aborting with TBROK.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 lib/tst_cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index a37bf1516aabfbcb9a02fedd6fddb98e85ecc653..42d07912aebc0fae423b52f22c36c6beab0ee5c6 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -974,7 +974,7 @@ static void cgroup_drain(const enum tst_cg_ver ver,
 	for (tok = strtok(pid_list, "\n"); tok; tok = strtok(NULL, "\n")) {
 		ret = dprintf(fd, "%s", tok);
 
-		if (ret < (ssize_t)strlen(tok))
+		if (ret < (ssize_t)strlen(tok) && errno != ESRCH)
 			tst_brk(TBROK | TERRNO, "Failed to drain %s", tok);
 	}
 	SAFE_CLOSE(fd);

-- 
2.51.0


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

  parent reply	other threads:[~2026-06-15 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-15 14:16 [LTP] [PATCH 0/2] Fix sporadic failures in pids shell tests Andrea Cervesato
2026-06-15 14:16 ` [LTP] [PATCH 1/2] pids: fix cleanup of orphaned pids_task1 children Andrea Cervesato
2026-06-15 14:40   ` [LTP] " linuxtestproject.agent
2026-06-16  7:32   ` [LTP] [PATCH 1/2] " Li Wang
2026-06-15 14:16 ` Andrea Cervesato [this message]
2026-06-16  8:03   ` [LTP] [PATCH 2/2] tst_cgroup: tolerate ESRCH in cgroup_drain() 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=20260615-fix_pids_errors-v1-2-99a54a205180@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.