With this change, parse_argv() does parsing, without any real actions.
Fully untested ;)
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <getopt.h>
+#include <unistd.h>
#include "alloc-util.h"
#include "pretty-print.h"
+#include "rlimit-util.h"
#include "systemctl-compat-telinit.h"
#include "systemctl-daemon-reload.h"
#include "systemctl-start-unit.h"
return 0;
}
+
+int exec_telinit(char *argv[]) {
+ (void) rlimit_nofile_safe();
+ execv(TELINIT, argv);
+
+ return log_error_errno(SYNTHETIC_ERRNO(EIO),
+ "Couldn't find an alternative telinit implementation to spawn.");
+}
int telinit_parse_argv(int argc, char *argv[]);
int start_with_fallback(void);
int reload_with_fallback(void);
+int exec_telinit(char *argv[]);
/* Hmm, so some other init system is running, we need to forward this request
* to it. */
- (void) rlimit_nofile_safe();
- execv(TELINIT, argv);
-
- return log_error_errno(SYNTHETIC_ERRNO(EIO),
- "Couldn't find an alternative telinit implementation to spawn.");
+ arg_action = ACTION_TELINIT;
+ return 1;
}
} else if (strstr(program_invocation_short_name, "runlevel")) {
r = runlevel_main();
break;
+ case ACTION_TELINIT:
+ r = exec_telinit(argv);
+ break;
+
case ACTION_EXIT:
case ACTION_SUSPEND:
case ACTION_HIBERNATE:
ACTION_RELOAD,
ACTION_REEXEC,
ACTION_RUNLEVEL,
+ ACTION_TELINIT,
ACTION_CANCEL_SHUTDOWN,
_ACTION_MAX,
_ACTION_INVALID = -1