1) add a parameter for kill_children() and replace the for-loop(s) of kill() with it.
2) free the memory after killing children process. Signed-off-by: Wei,Jiangang <weijg.f...@cn.fujitsu.com> --- .../conformance/interfaces/sched_setparam/9-1.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c index 48ef1b0..24fe761 100644 --- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c +++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c @@ -131,12 +131,13 @@ static void test_process(void) pause(); } -static void kill_children(int *child_pid) +static void kill_children(int *child_pid, int count) { int i; - for (i = 0; i < nb_cpu; i++) + for (i = 0; i < count; i++) kill(child_pid[i], SIGTERM); + free(child_pid); } int main(void) @@ -191,9 +192,7 @@ int main(void) child_pid[i] = fork(); if (child_pid[i] == -1) { perror("An error occurs when calling fork()"); - for (j = 0; j < i; j++) - kill(child_pid[j], SIGTERM); - + kill_children(child_pid, i) return PTS_UNRESOLVED; } else if (child_pid[i] == 0) { @@ -207,9 +206,7 @@ int main(void) child_pid[i] = fork(); if (child_pid[i] == -1) { perror("An error occurs when calling fork()"); - for (j = 0; j < i; j++) - kill(child_pid[j], SIGTERM); - + kill_children(child_pid, i); return PTS_UNRESOLVED; } else if (child_pid[i] == 0) { @@ -223,7 +220,7 @@ int main(void) oldcount = *shmptr; if (sched_setparam(child_pid[i], ¶m) != 0) { perror("An error occurs when calling sched_setparam()"); - kill_children(child_pid); + kill_children(child_pid, nb_cpu); return PTS_UNRESOLVED; } newcount = *shmptr; @@ -231,11 +228,11 @@ int main(void) if (newcount == oldcount) { printf("The target process does not preempt" " the calling process\n"); - kill_children(child_pid); + kill_children(child_pid, nb_cpu); return PTS_FAIL; } printf("Test PASSED\n"); - kill_children(child_pid); + kill_children(child_pid, nb_cpu); return PTS_PASS; } -- 1.9.3 ------------------------------------------------------------------------------ _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list