From: Anders Roxell <anders.roxell@linaro.org>
To: ltp@lists.linux.it, pvorel@suse.cz
Subject: [LTP] [PATCH v3] tst_clone: Fix child detection on sparc
Date: Wed, 30 Sep 2026 22:14:30 +0200 [thread overview]
Message-ID: <20260930201430.1924463-1-anders.roxell@linaro.org> (raw)
On sparc the clone syscall returns the caller's thread id in the child,
not 0. So the child thinks it is the parent.
Compare with tst_gettid() in the clone fallback. clone3 returns 0, but
sparc only has it since v7.0.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
v2 -> v3: use tst_gettid(), the kernel returns the caller's thread id
to the child. And only get it in the clone fallback, as the AI review
suggested.
v1 -> v2: fixed the AI review comments, use tst_getpid() since glibc
before 2.25 caches getpid(), and only check after clone, so the goto
is gone.
lib/tst_clone.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index 296cd40ac0a0..a04c4042653b 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -35,6 +35,10 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
flags = args.exit_signal | args.flags;
+#ifdef __sparc__
+ pid_t tid = tst_gettid();
+#endif
+
#ifdef __s390x__
pid = syscall(__NR_clone, NULL, flags, args.pidfd, NULL, NULL);
#else
@@ -44,5 +48,10 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
if (pid == -1)
return -2;
+#ifdef __sparc__
+ if (pid == tid)
+ pid = 0;
+#endif
+
return pid;
}
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-09-30 20:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 20:14 Anders Roxell [this message]
2026-10-01 15:03 ` [LTP] [PATCH v3] tst_clone: Fix child detection on sparc Petr Vorel
2026-10-12 11:46 ` [LTP] " linuxtestproject.agent
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=20260930201430.1924463-1-anders.roxell@linaro.org \
--to=anders.roxell@linaro.org \
--cc=ltp@lists.linux.it \
--cc=pvorel@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox