4 systemd-analyze log-level debug
6 # Multiple level process tree, parent process stays up
7 cat >/tmp
/test56-exit-cgroup.sh
<<EOF
11 # process tree: systemd -> sleep
15 # process tree: systemd -> bash -> bash -> sleep
16 ((sleep infinity); true) &
18 systemd-notify --ready
20 # process tree: systemd -> bash -> sleep
23 chmod +x
/tmp
/test56-exit-cgroup.sh
25 # service should be stopped cleanly
26 systemd-run
--wait --unit=one
-p Type
=notify
-p ExitType
=cgroup \
27 -p ExecStartPost
='bash -c "systemctl stop one &"' \
28 /tmp
/test56-exit-cgroup.sh
30 # same thing with a truthy exec condition
31 systemd-run
--wait --unit=two
-p Type
=notify
-p ExitType
=cgroup \
32 -p ExecCondition
=true \
33 -p ExecStartPost
='bash -c "systemctl stop two &"' \
34 /tmp
/test56-exit-cgroup.sh
36 # false exec condition: systemd-run should exit immediately with status code: 1
37 systemd-run
--wait --unit=three
-p Type
=notify
-p ExitType
=cgroup \
38 -p ExecCondition
=false \
39 /tmp
/test56-exit-cgroup.sh \
40 && { echo 'unexpected success'; exit 1; }
42 # service should exit uncleanly (main process exits with SIGKILL)
43 systemd-run
--wait --unit=four
-p Type
=notify
-p ExitType
=cgroup \
44 -p ExecStartPost
='bash -c "systemctl kill --signal 9 four &"' \
45 /tmp
/test56-exit-cgroup.sh \
46 && { echo 'unexpected success'; exit 1; }
49 # Multiple level process tree, parent process exits quickly
50 cat >/tmp
/test56-exit-cgroup-parentless.sh
<<EOF
54 # process tree: systemd -> sleep
57 # process tree: systemd -> bash -> sleep
58 ((sleep infinity); true) &
60 systemd-notify --ready
62 chmod +x
/tmp
/test56-exit-cgroup-parentless.sh
64 # service should be stopped cleanly
65 systemd-run
--wait --unit=five
-p Type
=notify
-p ExitType
=cgroup \
66 -p ExecStartPost
='bash -c "systemctl stop five &"' \
67 /tmp
/test56-exit-cgroup-parentless.sh
69 # service should still exit cleanly despite SIGKILL (the main process already exited cleanly)
70 systemd-run
--wait --unit=six
-p Type
=notify
-p ExitType
=cgroup \
71 -p ExecStartPost
='bash -c "systemctl kill --signal 9 six &"' \
72 /tmp
/test56-exit-cgroup-parentless.sh
75 systemd-analyze log-level info