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 # Run the stop/kill command
23 # process tree: systemd -> bash -> sleep
26 chmod +x
/tmp
/test56-exit-cgroup.sh
28 # service should be stopped cleanly
29 systemd-run
--wait --unit=one
-p Type
=notify
-p ExitType
=cgroup \
30 /tmp
/test56-exit-cgroup.sh
'systemctl stop one'
32 # same thing with a truthy exec condition
33 systemd-run
--wait --unit=two
-p Type
=notify
-p ExitType
=cgroup \
34 -p ExecCondition
=true \
35 /tmp
/test56-exit-cgroup.sh
'systemctl stop two'
37 # false exec condition: systemd-run should exit immediately with status code: 1
38 systemd-run
--wait --unit=three
-p Type
=notify
-p ExitType
=cgroup \
39 -p ExecCondition
=false \
40 /tmp
/test56-exit-cgroup.sh \
41 && { echo 'unexpected success'; exit 1; }
43 # service should exit uncleanly (main process exits with SIGKILL)
44 systemd-run
--wait --unit=four
-p Type
=notify
-p ExitType
=cgroup \
45 /tmp
/test56-exit-cgroup.sh
'systemctl kill --signal 9 four' \
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 # Run the stop/kill command after this bash process exits
65 chmod +x
/tmp
/test56-exit-cgroup-parentless.sh
67 # service should be stopped cleanly
68 systemd-run
--wait --unit=five
-p Type
=notify
-p ExitType
=cgroup \
69 /tmp
/test56-exit-cgroup-parentless.sh
'systemctl stop five'
71 # service should still exit cleanly despite SIGKILL (the main process already exited cleanly)
72 systemd-run
--wait --unit=six
-p Type
=notify
-p ExitType
=cgroup \
73 /tmp
/test56-exit-cgroup-parentless.sh
'systemctl kill --signal 9 six'
76 systemd-analyze log-level info