fcntl/fcntl17: break test if fork failed
PATCH 1/1 fcntl/fcntl17: break test if fork failed
Or the kill() in catch_alarm() will use -1 as pid and kill a lot of processes.
Signed-off-by Han Pingtian <[email protected]>
--- testcases/kernel/syscalls/fcntl/fcntl17.c | 42 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-)
testcases/kernel/syscalls/fcntl/fcntl17.c +19 -23
@@ -160,6 +160,15 @@ int setup(void)void cleanup (void ) { +if (child_pid1 >0 ) +kill (child_pid1,9 ); + +if (child_pid2 >0 ) +kill (child_pid2,9 ); + +if (child_pid3 >0 ) +kill (child_pid3,9 ); +close (file_fd);tst_rmdir ();
@@ -466,10 +475,8 @@ int main(int ac, char **av)#else do_child1 ();#endif - }else if (child_pid1 <0 ) { -perror ("Fork failed: child 1" ); -cleanup (); - } + }else if (child_pid1 <0 ) +tst_brkm (TBROK |TERRNO , cleanup,"Fork failed: child 1" );/* parent */
@@ -487,12 +494,7 @@ int main(int ac, char **av)do_child2 ();#endif }else if (child_pid2 <0 ) { -perror ("Fork failed: child 2" ); -if ((kill (child_pid1,SIGKILL )) <0 ) { -tst_resm (TFAIL ,"Attempt to signal child " -"1 failed" ); - } -cleanup (); +tst_brkm (TBROK |TERRNO , cleanup,"Fork failed: child 2" ); }/* parent */
@@ -512,16 +514,7 @@ int main(int ac, char **av)#endif do_child3 (); }else if (child_pid3 <0 ) { -perror ("Fork failed: child 3" ); -if ((kill (child_pid1,SIGKILL )) <0 ) { -tst_resm (TFAIL ,"Attempt to signal child " -"1 failed" ); - } -if ((kill (child_pid2,SIGKILL )) <0 ) { -tst_resm (TFAIL ,"Attempt to signal child 2 " -"failed" ); - } -cleanup (); +tst_brkm (TBROK |TERRNO , cleanup,"Fork failed: child 3" ); }/* parent */
@@ -616,6 +609,12 @@ int main(int ac, char **av)do_test (&lock3, child_pid3);stop_children (); +waitpid (child_pid1, &child_stat,0 ); +waitpid (child_pid2, &child_stat,0 ); +waitpid (child_pid3, &child_stat,0 ); + child_pid1 =0 ; + child_pid2 =0 ; + child_pid3 =0 ;if (fail) {tst_resm (TINFO ,"Block 1 FAILED" ); }else {
@@ -623,9 +622,6 @@ int main(int ac, char **av) }tst_resm (TINFO ,"Exit block 1" ); } -waitpid (child_pid1, &child_stat,0 ); -waitpid (child_pid2, &child_stat,0 ); -waitpid (child_pid3, &child_stat,0 );cleanup ();tst_exit (); }
Signature · 1 line
1.9.3
PATCH 1/1 fcntl/fcntl17: break test if fork failed
Hi!
testcases/kernel/syscalls/fcntl/fcntl17.c int main(int ac, char **av) · line 617
Quoted 7 lines
testcases/kernel/syscalls/fcntl/fcntl17.c +6
-0stop_children (); +waitpid (child_pid1, &child_stat,0 ); +waitpid (child_pid2, &child_stat,0 ); +waitpid (child_pid3, &child_stat,0 ); + child_pid1 =0 ; + child_pid2 =0 ; + child_pid3 =0 ;
I've moved these lines to the stop_children() function and pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]