All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v3] tst_clone: Fix child detection on sparc
@ 2026-09-30 20:14 Anders Roxell
  2026-10-01 15:03 ` Petr Vorel
  2026-10-12 11:46 ` [LTP] " linuxtestproject.agent
  0 siblings, 2 replies; 3+ messages in thread
From: Anders Roxell @ 2026-09-30 20:14 UTC (permalink / raw)
  To: ltp, pvorel

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-12 11:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 20:14 [LTP] [PATCH v3] tst_clone: Fix child detection on sparc Anders Roxell
2026-10-01 15:03 ` Petr Vorel
2026-10-12 11:46 ` [LTP] " linuxtestproject.agent

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.