[LTP] [PATCH] test_children_cleanup: allow child zombied for a while

Petr Vorel pvorel@suse.cz
Sun Feb 13 17:57:16 CET 2022


Hi Li,

> Zombie process is already dead after SIGKILL is processed by the kernel,
> there's usually a kernel reason (similar to being "blocked" waiting on
> a syscall to finish) for the process not terminating.

> Due to this child having been moved under PID 1(init), there is no waitpid()
> guarantee of reaping it anymore. It completely depends on PID 1(init) reclaims
> zombie process at its own pace.

> So here allow the child exist in a zombie state if PID 1(init) does not
> reclaim resource and update the process table instantly.

> Failed CI:
>   https://github.com/linux-test-project/ltp/runs/5171298664?check_suite_focus=true

Good catch!

...
>   runtest TINFO: * test_children_cleanup.sh
>   TFAIL: Child process was left behind
>   cat /proc/69523/status
>   Name:	test_children_c
>   State:	Z (zombie)
>   Tgid:	69523
>   Ngid:	0
>   Pid:	69523
>   PPid:	1

...
> +++ b/lib/newlib_tests/test_children_cleanup.sh
> @@ -13,7 +13,13 @@ if [ "x$CHILD_PID" = "x" ]; then
>  elif ! kill -s 0 $CHILD_PID &>/dev/null; then
>  	echo "TPASS: Child process was cleaned up"
>  	exit 0
> +elif grep -q -E "Z|zombie" /proc/$CHILD_PID/status; then

task_state_array[] in fs/proc/array.c has "Z (zombie)"
Is there a reason to grep just "Z"? Because -E "Z|zombie" matches just "Z" and
when we don't grep for "State:" we can likely search for different result.
"Z (zombie)" is here form kernel git beginning (2.6.12-rc2), we should match it.

Kind regards,
Petr


More information about the ltp mailing list