mirror of
https://github.com/systemd/systemd.git
synced 2024-11-08 11:27:32 +03:00
287419c119
When a systemd service running in a container exits with a non-zero code, it can be useful to terminate the container immediately and get the exit code back to the host, when systemd-nspawn returns. This was not possible to do. This patch adds the following to make it possible: - Add a read-only "ExitCode" property on PID 1's "Manager" bus object. By default, it is 0 so the behaviour stays the same as previously. - Add a method "SetExitCode" on the same object. The method fails when called on baremetal: it is only allowed in containers or in user session. - Add support in systemctl to call "systemctl exit 42". It reuses the existing code for user session. - Add exit.target and systemd-exit.service to the system instance. - Change main() to actually call systemd-shutdown to exit() with the correct value. - Add verb 'exit' in systemd-shutdown with parameter --exit-code - Update systemctl manpage. I used the following to test it: | $ sudo rkt --debug --insecure-skip-verify run \ | --mds-register=false --local docker://busybox \ | --exec=/bin/chroot -- /proc/1/root \ | systemctl --force exit 42 | ... | Container rkt-895a0cba-5c66-4fa5-831c-e3f8ddc5810d failed with error code 42. | $ echo $? | 42 Fixes https://github.com/systemd/systemd/issues/1290
82 lines
2.1 KiB
Plaintext
82 lines
2.1 KiB
Plaintext
/systemd-bus-proxyd.service.m4
|
|
/user@.service.m4
|
|
/console-getty.service
|
|
/console-getty.service.m4
|
|
/console-shell.service
|
|
/console-shell.service.m4
|
|
/container-getty@.service
|
|
/container-getty@.service.m4
|
|
/debug-shell.service
|
|
/emergency.service
|
|
/getty@.service
|
|
/halt-local.service
|
|
/initrd-cleanup.service
|
|
/initrd-parse-etc.service
|
|
/initrd-switch-root.service
|
|
/initrd-udevadm-cleanup-db.service
|
|
/kmod-static-nodes.service
|
|
/quotaon.service
|
|
/rc-local.service
|
|
/rescue.service
|
|
/serial-getty@.service
|
|
/systemd-ask-password-console.service
|
|
/systemd-ask-password-wall.service
|
|
/systemd-backlight@.service
|
|
/systemd-binfmt.service
|
|
/systemd-bootchart.service
|
|
/systemd-bus-proxyd.service
|
|
/systemd-firstboot.service
|
|
/systemd-fsck-root.service
|
|
/systemd-fsck@.service
|
|
/systemd-machine-id-commit.service
|
|
/systemd-halt.service
|
|
/systemd-exit.service
|
|
/systemd-hibernate.service
|
|
/systemd-hostnamed.service
|
|
/systemd-hybrid-sleep.service
|
|
/systemd-importd.service
|
|
/systemd-initctl.service
|
|
/systemd-journal-catalog-update.service
|
|
/systemd-journal-flush.service
|
|
/systemd-journal-gatewayd.service
|
|
/systemd-journal-remote.service
|
|
/systemd-journal-upload.service
|
|
/systemd-journald.service
|
|
/systemd-kexec.service
|
|
/systemd-localed.service
|
|
/systemd-logind.service
|
|
/systemd-machined.service
|
|
/systemd-modules-load.service
|
|
/systemd-networkd-wait-online.service
|
|
/systemd-networkd.service
|
|
/systemd-networkd.service.m4
|
|
/systemd-nspawn@.service
|
|
/systemd-poweroff.service
|
|
/systemd-quotacheck.service
|
|
/systemd-random-seed.service
|
|
/systemd-reboot.service
|
|
/systemd-remount-fs.service
|
|
/systemd-resolved.service
|
|
/systemd-resolved.service.m4
|
|
/systemd-hibernate-resume@.service
|
|
/systemd-rfkill@.service
|
|
/systemd-suspend.service
|
|
/systemd-sysctl.service
|
|
/systemd-sysusers.service
|
|
/systemd-timedated.service
|
|
/systemd-timesyncd.service
|
|
/systemd-tmpfiles-clean.service
|
|
/systemd-tmpfiles-setup-dev.service
|
|
/systemd-tmpfiles-setup.service
|
|
/systemd-tmpfiles.service
|
|
/systemd-hwdb-update.service
|
|
/systemd-udev-settle.service
|
|
/systemd-udev-trigger.service
|
|
/systemd-udevd.service
|
|
/systemd-update-done.service
|
|
/systemd-update-utmp-runlevel.service
|
|
/systemd-update-utmp.service
|
|
/systemd-user-sessions.service
|
|
/systemd-vconsole-setup.service
|
|
/user@.service
|