1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

main: move install_crash_handler() and mount_cgroup_controllers() invocations

Let's place them in initialize_runtime(), where they appear to fit best.
Effectively this is just a move a little bit down, swapping places with
log_execution_mode(), which should require neither call to be done
first.

Note that changes the conditionalization a bit for these calls, from
(PID == 1) to (arg_system && arg_action == ACTION_RUN). At this point this is pretty much the same
however, as we don't allow PID 1 without ACTION_RUN and without
arg_system set, safety_checks() ensures that.
This commit is contained in:
Lennart Poettering 2017-12-15 17:34:12 +01:00
parent db33214b52
commit 3c3c6cb95d

View File

@ -1917,25 +1917,35 @@ static int initialize_runtime(
* - Some only apply when we first start up, but not when we reexecute
*/
if (arg_system && !skip_setup) {
status_welcome();
hostname_setup();
machine_id_setup(NULL, arg_machine_id, NULL);
loopback_setup();
bump_unix_max_dgram_qlen();
test_usr();
write_container_id();
}
if (arg_system) {
/* Make sure we leave a core dump without panicing the kernel. */
install_crash_handler();
if (arg_system && arg_watchdog_device) {
r = watchdog_set_device(arg_watchdog_device);
if (r < 0)
log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m",
arg_watchdog_device);
}
if (!skip_setup) {
r = mount_cgroup_controllers(arg_join_controllers);
if (r < 0) {
*ret_error_message = "Failed to mount cgroup hierarchies";
return r;
}
if (arg_system && arg_runtime_watchdog > 0 && arg_runtime_watchdog != USEC_INFINITY)
watchdog_set_timeout(&arg_runtime_watchdog);
status_welcome();
hostname_setup();
machine_id_setup(NULL, arg_machine_id, NULL);
loopback_setup();
bump_unix_max_dgram_qlen();
test_usr();
write_container_id();
}
if (arg_watchdog_device) {
r = watchdog_set_device(arg_watchdog_device);
if (r < 0)
log_warning_errno(r, "Failed to set watchdog device to %s, ignoring: %m", arg_watchdog_device);
}
if (arg_runtime_watchdog > 0 && arg_runtime_watchdog != USEC_INFINITY)
watchdog_set_timeout(&arg_runtime_watchdog);
}
if (arg_timer_slack_nsec != NSEC_INFINITY)
if (prctl(PR_SET_TIMERSLACK, arg_timer_slack_nsec) < 0)
@ -2467,16 +2477,6 @@ int main(int argc, char *argv[]) {
log_open();
}
/* Make sure we leave a core dump without panicing the
* kernel. */
if (getpid_cached() == 1) {
install_crash_handler();
r = mount_cgroup_controllers(arg_join_controllers);
if (r < 0)
goto finish;
}
log_execution_mode(&first_boot);
if (arg_action == ACTION_RUN) {