[LTP] [PATCH] syscalls/recvmsg01: wait for server to finish

Jan Stancek jstancek@redhat.com
Fri May 6 11:14:46 CEST 2022


When test finishes, cleanup of temporary directory (by library)
can be racing with server process still running sender() function
and trying to clean temp file "smtXXXXXX":
    ...
    recvmsg01   12  TPASS  :  large cmesg length successful
    recvmsg01    0  TWARN  :  tst_tmpdir.c:343: tst_rmdir: rmobj(/mnt/testarea/ltp-jj3j87RyWN/recnDC6uq)
                              failed: unlink(/mnt/testarea/ltp-jj3j87RyWN/recnDC6uq/smtlCpMTv)
                              failed; errno=2: ENOENT

Wait for server pid before proceeding with test cleanup.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/recvmsg/recvmsg01.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
index 13bcaa4e07c4..6b78a230ba04 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
@@ -268,8 +268,10 @@ void setup(void)
 
 void cleanup(void)
 {
-	if (pid > 0)
+	if (pid > 0) {
 		(void)kill(pid, SIGKILL);	/* kill server */
+		wait(NULL);
+	}
 	if (tmpsunpath[0] != '\0')
 		(void)unlink(tmpsunpath);
 	tst_rmdir();
-- 
2.27.0



More information about the ltp mailing list