public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] pidns05: Use tst_getpid()
@ 2023-09-20 15:31 Martin Doucha
  2023-09-20 15:37 ` Petr Vorel
  2023-09-22 12:13 ` Cyril Hrubis
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Doucha @ 2023-09-20 15:31 UTC (permalink / raw)
  To: Andrea Cervesato, ltp

Older glibc versions cache getpid() results. Calling clone() through
the direct syscall interface (bypassing glibc) with the CLONE_NEWPID
argument will result in stale getpid() cache and the test will fail.
Use tst_getpid() instead to get the correct PID value.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/kernel/containers/pidns/pidns05.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/containers/pidns/pidns05.c b/testcases/kernel/containers/pidns/pidns05.c
index ec9ce9bf2..0e7739aaa 100644
--- a/testcases/kernel/containers/pidns/pidns05.c
+++ b/testcases/kernel/containers/pidns/pidns05.c
@@ -28,7 +28,7 @@ static void child_func(int *level)
 {
 	pid_t cpid, ppid;
 
-	cpid = getpid();
+	cpid = tst_getpid();
 	ppid = getppid();
 
 	TST_EXP_EQ_LI(cpid, 1);
@@ -55,7 +55,7 @@ static int find_cinit_pids(pid_t *pids)
 	int next = 0;
 	pid_t parentpid, pgid, pgid2;
 
-	parentpid = getpid();
+	parentpid = tst_getpid();
 	pgid = SAFE_GETPGID(parentpid);
 
 	for (pid = 2; pid < pid_max; pid++) {
-- 
2.42.0


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

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

end of thread, other threads:[~2023-09-25 17:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 15:31 [LTP] [PATCH] pidns05: Use tst_getpid() Martin Doucha
2023-09-20 15:37 ` Petr Vorel
2023-09-22 12:13 ` Cyril Hrubis
2023-09-25 13:12   ` Petr Vorel
2023-09-25 13:17     ` Cyril Hrubis
2023-09-25 17:45       ` Petr Vorel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox