All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Roxell <anders.roxell@linaro.org>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] tst_clone: Fix child detection on sparc
Date: Mon, 28 Sep 2026 23:27:13 +0200	[thread overview]
Message-ID: <20260928212713.2832800-1-anders.roxell@linaro.org> (raw)

On sparc the clone syscall does not return 0 in the child. It returns
the parent pid, so the child thinks it is the parent.

Save the pid before the clone and compare it after.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 lib/tst_clone.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/tst_clone.c b/lib/tst_clone.c
index 296cd40ac0a0..2fdd9e163717 100644
--- a/lib/tst_clone.c
+++ b/lib/tst_clone.c
@@ -20,6 +20,9 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
 	};
 	int flags;
 	pid_t pid = -1;
+#ifdef __sparc__
+	pid_t parent_pid = getpid();
+#endif
 
 	tst_flush();
 
@@ -31,7 +34,7 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
 		return -1;
 
 	if (pid != -1)
-		return pid;
+		goto out;
 
 	flags = args.exit_signal | args.flags;
 
@@ -44,5 +47,11 @@ pid_t tst_clone(const struct tst_clone_args *tst_args)
 	if (pid == -1)
 		return -2;
 
+out:
+#ifdef __sparc__
+	if (getpid() != parent_pid)
+		pid = 0;
+#endif
+
 	return pid;
 }
-- 
2.53.0


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

             reply	other threads:[~2026-09-28 21:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 21:27 Anders Roxell [this message]
2026-09-28 23:51 ` [LTP] tst_clone: Fix child detection on sparc 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=20260928212713.2832800-1-anders.roxell@linaro.org \
    --to=anders.roxell@linaro.org \
    --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.