lib/tst_test.c: Bugfix for heartbeat
PATCH 1/1 lib/tst_test.c: Bugfix for heartbeat
Hi Cyril,
According to your review, is there any problems in the patch as follows:
lib/tst_test.c +10 -1
@@ -1156,7 +1156,16 @@ static void heartbeat(void)if (tst_clock_gettime (CLOCK_MONOTONIC , &tst_start_time))tst_res (TWARN |TERRNO ,"tst_clock_gettime() failed" ); -kill (getppid (),SIGUSR1 ); +if (getppid () ==1 ) { +tst_res (TFAIL ,"Main test process might have exit!" ); +/* +* We need kill the task group immediately since the +* main process has exit. +*/ +kill (0 ,SIGKILL ); +exit (-1 ); + }else +kill (getppid (),SIGUSR1 ); }
Thanks so much!
Best Regards,
Gongyi
Quoted 24 lines
Hi!
Quoted 10 lines
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* + * We need kill the task group immediately since the + * main process has exit. + */ + kill(0, SIGKILL);Shouldn't we call exit here? There is no point in continuing once we reached this point.
Quoted 5 lines
Yes, There is no point in continuing once we reached this point. Considering the test might have created sub processes with system,
posix_spawnand so on,do we need to kill the task group?
Yes, I think this is the right course of action, we do the same if the test timeouts as well.
--
Cyril Hrubis
[email protected]
PATCH 1/1 lib/tst_test.c: Bugfix for heartbeat
Hi!
Quoted 9 lines
According to your review, is there any problems in the patch as follows:
lib/tst_test.c +0
-0@@ -1156,7 +1156,16 @@ static void heartbeat(void)if (tst_clock_gettime (CLOCK_MONOTONIC , &tst_start_time))tst_res (TWARN |TERRNO ,"tst_clock_gettime() failed" );
lib/tst_test.c static void heartbeat(void) · line 1166
Quoted 10 lines
lib/tst_test.c +8
-1-kill (getppid (),SIGUSR1 ); +if (getppid () ==1 ) { +tst_res (TFAIL ,"Main test process might have exit!" ); +/* +* We need kill the task group immediately since the +* main process has exit. +*/ +kill (0 ,SIGKILL ); +exit (-1 );
Not that it matters that much, but I would do exit(TBROK);
lib/tst_test.c static void heartbeat(void) · line 1168
Quoted 2 lines
lib/tst_test.c +2
-0+ }else +kill (getppid (),SIGUSR1 );
No need for the else branch here now that we do exit() a the end of the if () block.
Other than that it looks good.
Signature · 2 lines
Cyril Hrubis [email protected]