File: test-zombies

package info (click to toggle)
dumb-init 1.2.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 268 kB
  • sloc: python: 677; ansic: 260; makefile: 86; sh: 49
file content (19 lines) | stat: -rwxr-xr-x 623 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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
# 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).
set -o pipefail

bash -euxc "bash -euxc 'echo i am a zombie' &" &

sleep 1
num_zombies=$(ps -A -o state | (grep 'Z' || true) | wc -l)

if [ "$num_zombies" -ne 0 ]; then
    echo "Expected no zombies, but instead there were ${num_zombies}."
    exit 1
fi