summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-11-16 11:48:45 +0100
committerLennart Poettering <lennart@poettering.net>2017-11-17 11:28:17 +0100
commit6808a0bc8016cd826237744d9fd3032ae6c7f2c4 (patch)
tree78e5a765f367284eef897ea84ef7951ffa430c93 /src
parent7b46fc6adc51d243ae44fe6868fadf084f766ae2 (diff)
downloadsystemd-6808a0bc8016cd826237744d9fd3032ae6c7f2c4.tar.gz
systemd-6808a0bc8016cd826237744d9fd3032ae6c7f2c4.tar.bz2
systemd-6808a0bc8016cd826237744d9fd3032ae6c7f2c4.zip
core: let's shorten main() a bit, let's split out telinit redirection into a separate function
Diffstat (limited to 'src')
-rw-r--r--src/core/main.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 65715c059b..3ba17eea17 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1399,6 +1399,23 @@ static int fixup_environment(void) {
return 0;
}
+static void redirect_telinit(int argc, char *argv[]) {
+
+ /* This is compatibility support for SysV, where calling init as a user is identical to telinit. */
+
+#if HAVE_SYSV_COMPAT
+ if (getpid_cached() == 1)
+ return;
+
+ if (!strstr(program_invocation_short_name, "init"))
+ return;
+
+ execv(SYSTEMCTL_BINARY_PATH, argv);
+ log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
+ exit(1);
+#endif
+}
+
int main(int argc, char *argv[]) {
Manager *m = NULL;
int r, retval = EXIT_FAILURE;
@@ -1423,16 +1440,7 @@ int main(int argc, char *argv[]) {
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0), saved_rlimit_memlock = RLIMIT_MAKE_CONST((rlim_t) -1);
const char *error_message = NULL;
-#if HAVE_SYSV_COMPAT
- if (getpid_cached() != 1 && strstr(program_invocation_short_name, "init")) {
- /* This is compatibility support for SysV, where
- * calling init as a user is identical to telinit. */
-
- execv(SYSTEMCTL_BINARY_PATH, argv);
- log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
- return 1;
- }
-#endif
+ redirect_telinit(argc, argv);
dual_timestamp_from_monotonic(&kernel_timestamp, 0);
dual_timestamp_get(&userspace_timestamp);