2015-09-11 03:00:25 +03:00
|
|
|
#!/bin/bash -eux
|
|
|
|
# Spawn a zombie process, and ensure it gets reaped.
|
|
|
|
# This test is only useful when run on an empty container with
|
|
|
|
# dumb-init as PID1.
|
|
|
|
#
|
|
|
|
# We run it as the last step of the integration tests inside our Docker
|
2015-09-12 03:24:18 +03:00
|
|
|
# containers. Since dumb-init must run as PID 1, we don't use pytest and
|
|
|
|
# instead write it in bash (which gets executed by PID1 dumb-init).
|
2016-01-08 01:30:09 +03:00
|
|
|
set -o pipefail
|
2015-09-11 03:00:25 +03:00
|
|
|
|
|
|
|
bash -euxc "bash -euxc 'echo i am a zombie' &" &
|
|
|
|
|
|
|
|
sleep 1
|
2016-01-08 01:30:09 +03:00
|
|
|
num_zombies=$(ps -A -o state | (grep 'Z' || true) | wc -l)
|
2015-09-11 03:00:25 +03:00
|
|
|
|
|
|
|
if [ "$num_zombies" -ne 0 ]; then
|
|
|
|
echo "Expected no zombies, but instead there were ${num_zombies}."
|
|
|
|
exit 1
|
|
|
|
fi
|