1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00

core: properly use the ExitCode bus property when exiting is --user instance

This commit is contained in:
Lennart Poettering 2015-09-23 19:50:10 +02:00
parent 5f5d8eab1f
commit 97792515b4

View File

@ -1168,7 +1168,6 @@ int main(int argc, char *argv[]) {
char *switch_root_dir = NULL, *switch_root_init = NULL; char *switch_root_dir = NULL, *switch_root_init = NULL;
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0); struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0);
const char *error_message = NULL; const char *error_message = NULL;
uint8_t shutdown_exit_code = 0;
#ifdef HAVE_SYSV_COMPAT #ifdef HAVE_SYSV_COMPAT
if (getpid() != 1 && strstr(program_invocation_short_name, "init")) { if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
@ -1720,8 +1719,9 @@ int main(int argc, char *argv[]) {
goto finish; goto finish;
case MANAGER_EXIT: case MANAGER_EXIT:
retval = m->return_value;
if (m->running_as == MANAGER_USER) { if (m->running_as == MANAGER_USER) {
retval = EXIT_SUCCESS;
log_debug("Exit."); log_debug("Exit.");
goto finish; goto finish;
} }
@ -1754,10 +1754,8 @@ int main(int argc, char *argv[]) {
finish: finish:
pager_close(); pager_close();
if (m) { if (m)
arg_shutdown_watchdog = m->shutdown_watchdog; arg_shutdown_watchdog = m->shutdown_watchdog;
shutdown_exit_code = m->return_value;
}
m = manager_free(m); m = manager_free(m);
@ -1930,7 +1928,7 @@ finish:
if (streq(shutdown_verb, "exit")) { if (streq(shutdown_verb, "exit")) {
command_line[pos++] = "--exit-code"; command_line[pos++] = "--exit-code";
command_line[pos++] = exit_code; command_line[pos++] = exit_code;
xsprintf(exit_code, "%d", shutdown_exit_code); xsprintf(exit_code, "%d", retval);
} }
assert(pos < ELEMENTSOF(command_line)); assert(pos < ELEMENTSOF(command_line));