[LTP] [PATCH] accept02: Add SAFE_FORK to clean CLOSE_WAIT fds

Cyril Hrubis chrubis@suse.cz
Wed Mar 23 16:06:30 CET 2022


Hi!
As far as I can tell we should rather close the fd returned from the
accept() call like this:

diff --git a/testcases/kernel/syscalls/accept/accept02.c b/testcases/kernel/syscalls/accept/accept02.c
index 12a1e3ca3..b2d27a260 100644
--- a/testcases/kernel/syscalls/accept/accept02.c
+++ b/testcases/kernel/syscalls/accept/accept02.c
@@ -68,6 +68,8 @@ static void *server_thread(void *arg)
        TEST(setsockopt(clone_server_sockfd, SOL_IP, MCAST_LEAVE_GROUP,
                        mc_group, mc_group_len));

+       SAFE_CLOSE(clone_server_sockfd);
+
        if (TST_RET != -1)
                tst_res(TFAIL, "Multicast group was copied!");
        else if (TST_ERR == EADDRNOTAVAIL)


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list