2 # SPDX-License-Identifier: LGPL-2.1-or-later
6 # shellcheck source=test/units/util.sh
7 .
"$(dirname "$0")"/util.sh
9 export SYSTEMD_LOG_LEVEL
=debug
11 # Create service with KillMode=none inside a slice
12 cat <<EOF >/run/systemd/system/test19cleanup.service
14 Description=Test 19 cleanup Service
16 Slice=test19cleanup.slice
18 ExecStart=sleep infinity
21 cat <<EOF >/run/systemd/system/test19cleanup.slice
23 Description=Test 19 cleanup Slice
27 systemctl start test19cleanup.service
28 assert_rc
0 systemd-cgls
/test19cleanup.slice
30 pid
=$
(systemctl show
--property MainPID
--value test19cleanup
)
34 # The sleep process will not be killed because of KillMode=none
35 # Since there is still a process running under it, the /test19cleanup.slice cgroup won't be removed
36 systemctl stop test19cleanup.slice
40 # Kill sleep process manually
42 while kill -0 "$pid" 2>/dev
/null
; do sleep 0.1; done
44 timeout
30 bash
-c 'while systemd-cgls /test19cleanup.slice/test19cleanup.service >& /dev/null; do sleep .5; done'
45 assert_rc
1 systemd-cgls
/test19cleanup.slice
/test19cleanup.service
47 # Check that empty cgroup /test19cleanup.slice has been removed
48 timeout
30 bash
-c 'while systemd-cgls /test19cleanup.slice >& /dev/null; do sleep .5; done'
49 assert_rc
1 systemd-cgls
/test19cleanup.slice