[LTP] [PATCH v1 2/2] Refactor pidns04 test using new LTP API

Cyril Hrubis chrubis@suse.cz
Fri Aug 5 15:05:26 CEST 2022


Hi!
> -static void cleanup(void)
> +static void run(void)
>  {
> -	close(fd[0]);
> +	int ret;
> +
> +	ret = ltp_clone_quick(CLONE_NEWPID | SIGCHLD, child_func, NULL);
> +	if (ret < 0)
> +		tst_brk(TBROK | TERRNO, "clone failed");

I think that it may be cleaner to wait() the child here since if we
manage to kill the child the test will end up with:

tst_test.c:381: TBROK: Child (26434) killed by signal SIGKILL

so maybe add:

	SAFE_WAITPID(ret, &status, 0);

	if (WIFEXITTED(status) && WEXITSTATUS(status) == 0)
		return;

	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) {
		tst_res(TFAIL, "Child killed by SIGKILL");
		return;
	}

	tst_res(TBROK, "Child %s", tst_strstatus(status));


But maybe the clearer message is not worth the effort here.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list