a->pipe_fd = safe_close(a->pipe_fd);
/* If we reload/reexecute things we keep the mount point around */
- if (!IN_SET(UNIT(a)->manager->exit_code, MANAGER_RELOAD, MANAGER_REEXECUTE)) {
+ if (!IN_SET(UNIT(a)->manager->objective, MANAGER_RELOAD, MANAGER_REEXECUTE)) {
automount_send_ready(a, a->tokens, -EHOSTDOWN);
automount_send_ready(a, a->expire_tokens, -EHOSTDOWN);
if (r < 0)
return r;
- m->exit_code = MANAGER_RELOAD;
+ m->objective = MANAGER_RELOAD;
return 1;
}
/* We don't send a reply back here, the client should
* just wait for us disconnecting. */
- m->exit_code = MANAGER_REEXECUTE;
+ m->objective = MANAGER_REEXECUTE;
return 1;
}
* systemd-shutdown if it cannot do the exit() because it isn't a
* container. */
- m->exit_code = MANAGER_EXIT;
+ m->objective = MANAGER_EXIT;
return sd_bus_reply_method_return(message, NULL);
}
if (!MANAGER_IS_SYSTEM(m))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Reboot is only supported for system managers.");
- m->exit_code = MANAGER_REBOOT;
+ m->objective = MANAGER_REBOOT;
return sd_bus_reply_method_return(message, NULL);
}
if (!MANAGER_IS_SYSTEM(m))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Powering off is only supported for system managers.");
- m->exit_code = MANAGER_POWEROFF;
+ m->objective = MANAGER_POWEROFF;
return sd_bus_reply_method_return(message, NULL);
}
if (!MANAGER_IS_SYSTEM(m))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Halt is only supported for system managers.");
- m->exit_code = MANAGER_HALT;
+ m->objective = MANAGER_HALT;
return sd_bus_reply_method_return(message, NULL);
}
if (!MANAGER_IS_SYSTEM(m))
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "KExec is only supported for system managers.");
- m->exit_code = MANAGER_KEXEC;
+ m->objective = MANAGER_KEXEC;
return sd_bus_reply_method_return(message, NULL);
}
free(m->switch_root_init);
m->switch_root_init = ri;
- m->exit_code = MANAGER_SWITCH_ROOT;
+ m->objective = MANAGER_SWITCH_ROOT;
return sd_bus_reply_method_return(message, NULL);
}
* in user mode */
log_warning("Exiting: %s", reason);
- m->exit_code = MANAGER_EXIT;
+ m->objective = MANAGER_EXIT;
return -ECANCELED;
}
log_and_status(m, "Forcibly rebooting", reason);
(void) update_reboot_parameter_and_warn(reboot_arg);
- m->exit_code = MANAGER_REBOOT;
+ m->objective = MANAGER_REBOOT;
break;
case EMERGENCY_ACTION_POWEROFF_FORCE:
log_and_status(m, "Forcibly powering off", reason);
- m->exit_code = MANAGER_POWEROFF;
+ m->objective = MANAGER_POWEROFF;
break;
case EMERGENCY_ACTION_POWEROFF_IMMEDIATE:
return log_emergency_errno(r, "Failed to run main loop: %m");
}
- switch (m->exit_code) {
+ switch (m->objective) {
case MANAGER_RELOAD: {
LogTarget saved_log_target;
case MANAGER_POWEROFF:
case MANAGER_HALT:
case MANAGER_KEXEC: {
- static const char * const table[_MANAGER_EXIT_CODE_MAX] = {
- [MANAGER_EXIT] = "exit",
- [MANAGER_REBOOT] = "reboot",
+ static const char * const table[_MANAGER_OBJECTIVE_MAX] = {
+ [MANAGER_EXIT] = "exit",
+ [MANAGER_REBOOT] = "reboot",
[MANAGER_POWEROFF] = "poweroff",
- [MANAGER_HALT] = "halt",
- [MANAGER_KEXEC] = "kexec"
+ [MANAGER_HALT] = "halt",
+ [MANAGER_KEXEC] = "kexec",
};
log_notice("Shutting down.");
*ret_reexecute = false;
*ret_retval = m->return_value;
- assert_se(*ret_shutdown_verb = table[m->exit_code]);
+ assert_se(*ret_shutdown_verb = table[m->objective]);
*ret_fds = NULL;
*ret_switch_root_dir = *ret_switch_root_init = NULL;
}
default:
- assert_not_reached("Unknown exit code.");
+ assert_not_reached("Unknown or unexpected manager objective.");
}
}
}
return -ENOMEM;
m->unit_file_scope = scope;
- m->exit_code = _MANAGER_EXIT_CODE_INVALID;
+ m->objective = _MANAGER_OBJECTIVE_INVALID;
m->default_timer_accuracy_usec = USEC_PER_MINUTE;
m->default_memory_accounting = MEMORY_ACCOUNTING_DEFAULT;
m->default_tasks_accounting = true;
unit_vtable[c]->shutdown(m);
/* If we reexecute ourselves, we keep the root cgroup around */
- manager_shutdown_cgroup(m, m->exit_code != MANAGER_REEXECUTE);
+ manager_shutdown_cgroup(m, m->objective != MANAGER_REEXECUTE);
lookup_paths_flush_generator(&m->lookup_paths);
/* This is for compatibility with the original sysvinit */
r = verify_run_space_and_log("Refusing to reexecute");
if (r >= 0)
- m->exit_code = MANAGER_REEXECUTE;
+ m->objective = MANAGER_REEXECUTE;
break;
}
case SIGHUP:
r = verify_run_space_and_log("Refusing to reload");
if (r >= 0)
- m->exit_code = MANAGER_RELOAD;
+ m->objective = MANAGER_RELOAD;
break;
default: {
};
/* Starting SIGRTMIN+13, so that target halt and system halt are 10 apart */
- static const ManagerExitCode code_table[] = {
+ static const ManagerObjective objective_table[] = {
[0] = MANAGER_HALT,
[1] = MANAGER_POWEROFF,
[2] = MANAGER_REBOOT,
}
if ((int) sfsi.ssi_signo >= SIGRTMIN+13 &&
- (int) sfsi.ssi_signo < SIGRTMIN+13+(int) ELEMENTSOF(code_table)) {
- m->exit_code = code_table[sfsi.ssi_signo - SIGRTMIN - 13];
+ (int) sfsi.ssi_signo < SIGRTMIN+13+(int) ELEMENTSOF(objective_table)) {
+ m->objective = objective_table[sfsi.ssi_signo - SIGRTMIN - 13];
break;
}
case 24:
if (MANAGER_IS_USER(m)) {
- m->exit_code = MANAGER_EXIT;
+ m->objective = MANAGER_EXIT;
return 0;
}
RATELIMIT_DEFINE(rl, 1*USEC_PER_SEC, 50000);
assert(m);
- m->exit_code = MANAGER_OK;
+ m->objective = MANAGER_OK;
/* Release the path cache */
m->unit_path_cache = set_free_free(m->unit_path_cache);
if (r < 0)
return log_error_errno(r, "Failed to enable SIGCHLD event source: %m");
- while (m->exit_code == MANAGER_OK) {
+ while (m->objective == MANAGER_OK) {
usec_t wait_usec;
if (m->runtime_watchdog > 0 && m->runtime_watchdog != USEC_INFINITY && MANAGER_IS_SYSTEM(m))
return log_error_errno(r, "Failed to run event loop: %m");
}
- return m->exit_code;
+ return m->objective;
}
int manager_load_unit_from_dbus_path(Manager *m, const char *s, sd_bus_error *e, Unit **_u) {
_MANAGER_STATE_INVALID = -1
} ManagerState;
-typedef enum ManagerExitCode {
+typedef enum ManagerObjective {
MANAGER_OK,
MANAGER_EXIT,
MANAGER_RELOAD,
MANAGER_HALT,
MANAGER_KEXEC,
MANAGER_SWITCH_ROOT,
- _MANAGER_EXIT_CODE_MAX,
- _MANAGER_EXIT_CODE_INVALID = -1
-} ManagerExitCode;
+ _MANAGER_OBJECTIVE_MAX,
+ _MANAGER_OBJECTIVE_INVALID = -1
+} ManagerObjective;
typedef enum StatusType {
STATUS_TYPE_EPHEMERAL,
usec_t etc_localtime_mtime;
bool etc_localtime_accessible:1;
- /* Flags */
- ManagerExitCode exit_code:5;
+ ManagerObjective objective:5;
+ /* Flags */
bool dispatching_load_queue:1;
bool dispatching_dbus_queue:1;
#define MANAGER_IS_FINISHED(m) (dual_timestamp_is_set((m)->timestamps + MANAGER_TIMESTAMP_FINISH))
-/* The exit code is set to OK as soon as we enter the main loop, and set otherwise as soon as we are done with it */
-#define MANAGER_IS_RUNNING(m) ((m)->exit_code == MANAGER_OK)
+/* The objective is set to OK as soon as we enter the main loop, and set otherwise as soon as we are done with it */
+#define MANAGER_IS_RUNNING(m) ((m)->objective == MANAGER_OK)
int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **m);
Manager* manager_free(Manager *m);