[LTP] [PATCH] pidns05: Use tst_getpid()
Martin Doucha
mdoucha@suse.cz
Wed Sep 20 17:31:40 CEST 2023
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
More information about the ltp
mailing list