In many instances waitid() syscall is used only to wait for the child process to exit and syscall out parameters struct siginfo and rusage are not used.
Introduce and utilize the lightweight waitpid() syscall which suits best in such instances.
Signed-off-by: Amit Daniel Kachhap amit.kachhap@arm.com --- tools/testing/selftests/arm64/morello/clone.c | 4 ++-- tools/testing/selftests/arm64/morello/freestanding.h | 5 +++++ tools/testing/selftests/arm64/morello/signal.c | 12 ++++++------ 3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/arm64/morello/clone.c b/tools/testing/selftests/arm64/morello/clone.c index a511054f90fa..60514fa5f869 100644 --- a/tools/testing/selftests/arm64/morello/clone.c +++ b/tools/testing/selftests/arm64/morello/clone.c @@ -461,8 +461,8 @@ void run_clone3(struct clone3_fixture *data) ASSERT_EQ(result, 0); }
- result = waitid(P_PID, pid, &wait_si, WEXITED, NULL); - ASSERT_EQ(result, 0); + result = waitpid(pid, NULL, 0); + ASSERT_EQ(result, pid);
/* child_tid set once the thread gets scheduled */ if (args->flags & CLONE_PARENT_SETTID && args->flags & CLONE_CHILD_SETTID diff --git a/tools/testing/selftests/arm64/morello/freestanding.h b/tools/testing/selftests/arm64/morello/freestanding.h index 19611b315de9..0b0de05d46bc 100644 --- a/tools/testing/selftests/arm64/morello/freestanding.h +++ b/tools/testing/selftests/arm64/morello/freestanding.h @@ -213,4 +213,9 @@ static inline int waitid(int id_type, pid_t id, siginfo_t *info, int options, st return syscall(__NR_waitid, id_type, id, info, options, ru); }
+static inline int waitpid(pid_t pid, int *wstatus, int options) +{ + return syscall(__NR_wait4, pid, wstatus, options, 0); +} + #endif diff --git a/tools/testing/selftests/arm64/morello/signal.c b/tools/testing/selftests/arm64/morello/signal.c index 3dcea434275c..32807b162f36 100644 --- a/tools/testing/selftests/arm64/morello/signal.c +++ b/tools/testing/selftests/arm64/morello/signal.c @@ -302,7 +302,7 @@ TEST(test_rt_sigqueueinfo)
TEST(test_rt_tgsigqueueinfo) { - siginfo_t si, wait_si; + siginfo_t si; pid_t cpid; struct sigaction sa; int ret; @@ -324,15 +324,15 @@ TEST(test_rt_tgsigqueueinfo) ASSERT_EQ(ret, 0) { __TH_LOG_ERROR("rt_tgsigqueueinfo syscall failed"); } - ret = waitid(P_PID, cpid, &wait_si, WEXITED, NULL); - ASSERT_EQ(ret, 0) { + ret = waitpid(cpid, NULL, 0); + ASSERT_EQ(ret, cpid) { __TH_LOG_ERROR("test_rt_tgsigqueueinfo: Failed on wait"); } }
TEST(test_pidfd_send_signal) { - siginfo_t si, wait_si; + siginfo_t si; pid_t cpid; int pidfd, ret; struct sigaction sa; @@ -364,8 +364,8 @@ TEST(test_pidfd_send_signal) ASSERT_EQ(ret, 0) { __TH_LOG_ERROR("pidfd_send_signal syscall failed"); } - ret = waitid(P_PID, cpid, &wait_si, WEXITED, NULL); - ASSERT_EQ(ret, 0) { + ret = waitpid(cpid, NULL, 0); + ASSERT_EQ(ret, cpid) { __TH_LOG_ERROR("test_pidfd_send_signal: Failed on wait"); } close(pidfd);