[LTP] tst_clone: Fix child detection on sparc

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Tue Sep 29 01:51:38 CEST 2026


Hi Anders,

On Mon Sep 28 23:27:13 2026 +0200, Anders Roxell <anders.roxell@linaro.org> wrote:
> tst_clone: Fix child detection on sparc

> +#ifdef __sparc__
> +	pid_t parent_pid = getpid();
> +#endif

Use tst_getpid() instead of getpid(). glibc versions prior to 2.25 cache
getpid(), which returns a stale PID if tst_clone() is called from a child
process created by a direct clone syscall.

> +out:
> +#ifdef __sparc__
> +	if (getpid() != parent_pid)
> +		pid = 0;
> +#endif

Calling getpid() in the child returns the cached parent PID on glibc < 2.25
because the raw clone syscall bypasses glibc, causing child detection to fail.
Use if (pid == parent_pid) pid = 0; instead, or use tst_getpid().

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list