diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-11-16 12:02:39 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-11-17 11:28:17 +0100 |
commit | 1e41242e11e33888234c2ac8ef0e57f9efc90e71 (patch) | |
tree | 7fe8893caf087e9a64088a87ba931e32006f9307 /src/core/main.c | |
parent | main: let's make main() shorter, let's split out clock initialization (diff) | |
download | systemd-1e41242e11e33888234c2ac8ef0e57f9efc90e71.tar.xz systemd-1e41242e11e33888234c2ac8ef0e57f9efc90e71.zip |
core: shorten main() a bit, split out coredump initialization
No functional changes.
Diffstat (limited to '')
-rw-r--r-- | src/core/main.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/core/main.c b/src/core/main.c index a6428cd4cc..a97c6e1f4e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1538,6 +1538,22 @@ static void initialize_clock(void) { log_info("System time before build time, advancing clock."); } +static void initialize_coredump(bool skip_setup) { + + if (getpid_cached() != 1) + return; + + /* Don't limit the core dump size, so that coredump handlers such as systemd-coredump (which honour the limit) + * will process core dumps for system services by default. */ + if (setrlimit(RLIMIT_CORE, &RLIMIT_MAKE_CONST(RLIM_INFINITY)) < 0) + log_warning_errno(errno, "Failed to set RLIMIT_CORE: %m"); + + /* But at the same time, turn off the core_pattern logic by default, so that no coredumps are stored + * until the systemd-coredump tool is enabled via sysctl. */ + if (!skip_setup) + (void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); +} + int main(int argc, char *argv[]) { Manager *m = NULL; int r, retval = EXIT_FAILURE; @@ -1672,17 +1688,7 @@ int main(int argc, char *argv[]) { kernel_timestamp = DUAL_TIMESTAMP_NULL; } - if (getpid_cached() == 1) { - /* Don't limit the core dump size, so that coredump handlers such as systemd-coredump (which honour the limit) - * will process core dumps for system services by default. */ - if (setrlimit(RLIMIT_CORE, &RLIMIT_MAKE_CONST(RLIM_INFINITY)) < 0) - log_warning_errno(errno, "Failed to set RLIMIT_CORE: %m"); - - /* But at the same time, turn off the core_pattern logic by default, so that no coredumps are stored - * until the systemd-coredump tool is enabled via sysctl. */ - if (!skip_setup) - (void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); - } + initialize_coredump(skip_setup); if (arg_system) { if (fixup_environment() < 0) { |