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

Li Wang liwang@redhat.com
Sun Feb 13 05:28:36 CET 2022


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

  -------------------
  runtest TINFO: * test_children_cleanup
  tst_test.c:1455: TINFO: Timeout per run is 0h 00m 10s
  test_children_cleanup.c:20: TINFO: Main process 69516 starting
  test_children_cleanup.c:35: TINFO: Forked child 69518
  tst_test.c:1500: TINFO: Killed the leftover descendant processes
  tst_test.c:1506: TINFO: If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1
  tst_test.c:1508: TBROK: Test killed! (timeout?)

  -------------------
  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
  ...

New test CI:
  https://github.com/wangli5665/ltp/runs/5171508466?check_suite_focus=true

Also, add some debug codes if test fails.

Signed-off-by: Li Wang <liwang@redhat.com>
Cc: Martin Doucha <mdoucha@suse.cz>
---
 lib/newlib_tests/test_children_cleanup.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/newlib_tests/test_children_cleanup.sh b/lib/newlib_tests/test_children_cleanup.sh
index 4b4e8b2f0..ec1a0d4fe 100755
--- a/lib/newlib_tests/test_children_cleanup.sh
+++ 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
+       echo "TPASS: Child process was in zombie state"
+       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
-- 
2.31.1



More information about the ltp mailing list