[LTP] [PATCH v3] syscalls/fanotify07: Add stop_children() to cleanup()

Zhao Gongyi zhaogongyi@huawei.com
Mon Nov 22 09:21:46 CET 2021


When we run the testcase simultaneously, and the ulimit of open
files is small, the testcase will fail and remain many while(1)
tasks in system, it makes the system very stuck.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
v2->v3: replace memset() with assignment statement in loop

 testcases/kernel/syscalls/fanotify/fanotify07.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/fanotify/fanotify07.c b/testcases/kernel/syscalls/fanotify/fanotify07.c
index cc56d9019..8220213b1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify07.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify07.c
@@ -86,13 +86,19 @@ static int stop_children(void)
 	int child_ret;
 	int i, ret = 0;

-	for (i = 0; i < MAX_CHILDREN; i++)
+	for (i = 0; i < MAX_CHILDREN; i++) {
+		if (!child_pid[i])
+			continue;
 		SAFE_KILL(child_pid[i], SIGKILL);
+	}

 	for (i = 0; i < MAX_CHILDREN; i++) {
+		if (!child_pid[i])
+			continue;
 		SAFE_WAITPID(child_pid[i], &child_ret, 0);
 		if (!WIFSIGNALED(child_ret))
 			ret = 1;
+		child_pid[i] = 0;
 	}

 	return ret;
@@ -190,6 +196,8 @@ static void setup(void)

 static void cleanup(void)
 {
+	stop_children();
+
 	if (fd_notify > 0)
 		SAFE_CLOSE(fd_notify);
 }
--
2.17.1



More information about the ltp mailing list