[LTP] [PATCH] waitpid/waitpid03: break test if fork failed

Cyril Hrubis chrubis@suse.cz
Wed Apr 13 14:55:35 CEST 2016


Hi!
> Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com>
> ---
>  testcases/kernel/syscalls/waitpid/waitpid03.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/waitpid/waitpid03.c b/testcases/kernel/syscalls/waitpid/waitpid03.c
> index 2599a92..7e9d45c 100644
> --- a/testcases/kernel/syscalls/waitpid/waitpid03.c
> +++ b/testcases/kernel/syscalls/waitpid/waitpid03.c
> @@ -106,7 +106,16 @@ int main(int argc, char **argv)
>  				if (DEBUG)
>  					tst_resm(TINFO, "child # %d", ikids);
>  			} else if (pid[ikids] == -1) {
> -				tst_resm(TFAIL, "cannot open fork #%d", ikids);
> +				int i;
> +
> +				tst_resm(TBROK|TERRNO, "cannot open fork #%d",
> +					 ikids);
> +
> +				for (i = 1; i < ikids; i++)
> +					kill(pid[i], 9);
> +
> +				cleanup();
> +				tst_exit();

This one is ugly. Why don't we kill the children in the test cleanup()
here as well. This should be easy, just store the number of allready
forked kids in a global variable and reset it to zero right after they
were killed in the main loop.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list