{"action":"created","issue":{"url":"https://api.github.com/repos/systemd/systemd/issues/1318","labels_url":"https://api.github.com/repos/systemd/systemd/issues/1318/labels{/name}","comments_url":"https://api.github.com/repos/systemd/systemd/issues/1318/comments","events_url":"https://api.github.com/repos/systemd/systemd/issues/1318/events","html_url":"https://github.com/systemd/systemd/pull/1318","id":107537448,"number":1318,"title":"containers: systemd exits with non-zero code","user":{"login":"alban","id":27575,"avatar_url":"https://avatars.githubusercontent.com/u/27575?v=3","gravatar_id":"","url":"https://api.github.com/users/alban","html_url":"https://github.com/alban","followers_url":"https://api.github.com/users/alban/followers","following_url":"https://api.github.com/users/alban/following{/other_user}","gists_url":"https://api.github.com/users/alban/gists{/gist_id}","starred_url":"https://api.github.com/users/alban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alban/subscriptions","organizations_url":"https://api.github.com/users/alban/orgs","repos_url":"https://api.github.com/users/alban/repos","events_url":"https://api.github.com/users/alban/events{/privacy}","received_events_url":"https://api.github.com/users/alban/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/systemd/systemd/labels/pid1","name":"pid1","color":"c7def8"},{"url":"https://api.github.com/repos/systemd/systemd/labels/systemctl","name":"systemctl","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-21T15:29:12Z","updated_at":"2015-09-21T15:47:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/systemd/systemd/pulls/1318","html_url":"https://github.com/systemd/systemd/pull/1318","diff_url":"https://github.com/systemd/systemd/pull/1318.diff","patch_url":"https://github.com/systemd/systemd/pull/1318.patch"},"body":"When a systemd service running in a container exits with a non-zero\r\ncode, it can be useful to terminate the container immediately and get\r\nthe exit code back to the host, when systemd-nspawn returns. This was\r\nnot possible to do. This patch adds the following to make it possible:\r\n\r\n- Add a read-only \"ExitCode\" property on PID 1's \"Manager\" bus object.\r\n  By default, it is 0 so the behaviour stays the same as previously.\r\n- Add a method \"SetExitCode\" on the same object. The method fails when\r\n  called on baremetal: it is only allowed in containers or in user\r\n  session.\r\n- Add support in systemctl to call \"systemctl exit 42\". It reuses the\r\n  existing code for user session.\r\n- Add exit.target and systemd-exit.service to the system instance.\r\n- Change main() to actually call systemd-shutdown to exit() with the\r\n  correct value.\r\n- Add verb 'exit' in systemd-shutdown with parameter --exit-code\r\n- Update systemctl manpage.\r\n\r\nI used the following to test it:\r\n\r\n| $ sudo rkt --debug --insecure-skip-verify run \\\r\n|            --mds-register=false --local docker://busybox \\\r\n|            --exec=/bin/chroot -- /proc/1/root \\\r\n|            systemctl --force exit 42\r\n| ...\r\n| Container rkt-895a0cba-5c66-4fa5-831c-e3f8ddc5810d failed with error code 42.\r\n| $ echo $?\r\n| 42\r\n\r\nFixes https://github.com/systemd/systemd/issues/1290"},"comment":{"url":"https://api.github.com/repos/systemd/systemd/issues/comments/142022437","html_url":"https://github.com/systemd/systemd/pull/1318#issuecomment-142022437","issue_url":"https://api.github.com/repos/systemd/systemd/issues/1318","id":142022437,"user":{"login":"alban","id":27575,"avatar_url":"https://avatars.githubusercontent.com/u/27575?v=3","gravatar_id":"","url":"https://api.github.com/users/alban","html_url":"https://github.com/alban","followers_url":"https://api.github.com/users/alban/followers","following_url":"https://api.github.com/users/alban/following{/other_user}","gists_url":"https://api.github.com/users/alban/gists{/gist_id}","starred_url":"https://api.github.com/users/alban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alban/subscriptions","organizations_url":"https://api.github.com/users/alban/orgs","repos_url":"https://api.github.com/users/alban/repos","events_url":"https://api.github.com/users/alban/events{/privacy}","received_events_url":"https://api.github.com/users/alban/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T15:47:36Z","updated_at":"2015-09-21T15:47:36Z","body":"Semaphore agreed!"}}