[LTP] [PATCH] test_children_cleanup.sh: Fix race condition
Petr Vorel
pvorel@suse.cz
Tue Feb 15 08:34:28 CET 2022
Hi all,
...
> It doesn't work for all platforms and we can not guarantee how long it will
> cost before PID 1 reaps zombie process.
> Also, I just get to know that Docker does not run processes under a
> special init process that properly reaps child processes, so that it is
> possible for the container to end up with zombie processes that cause
> all sorts of trouble.
> I even try adding `kill -SIGCHLD 1` but does not work as expected.
> See CI jobs:
> https://github.com/wangli5665/ltp/runs/5194270998?check_suite_focus=true
> <https://mail.google.com/mail/u/1/%E2%80%8Bhttps://github.com/wangli5665/ltp/runs/5194270998?check_suite_focus=true>
> Therefore, I suggest giving a chance to my refined patch V2 :).
> --- a/lib/newlib_tests/test_children_cleanup.sh
> +++ b/lib/newlib_tests/test_children_cleanup.sh
> @@ -10,10 +10,16 @@ rm "$TMPFILE"
> if [ "x$CHILD_PID" = "x" ]; then
> echo "TFAIL: Child process was not created"
> exit 1
> +elif grep -q "Z (zombie)" /proc/$CHILD_PID/status; then
> + echo "TPASS: Child process is in zombie state"
> + exit 0
> elif ! kill -s 0 $CHILD_PID &>/dev/null; then
> echo "TPASS: Child process was cleaned up"
> exit 0
> else
> echo "TFAIL: Child process was left behind"
> + echo "cat /proc/$CHILD_PID/status"
> + echo "---------------------------"
> + cat /proc/$CHILD_PID/status
> exit 1
> fi
Li's approach LGTM.
Kind regards,
Petr
More information about the ltp
mailing list