shutdown: convert to run() function
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include "killall.h"
|
#include "killall.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "luo-util.h"
|
#include "luo-util.h"
|
||||||
|
#include "main-func.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "parse-util.h"
|
#include "parse-util.h"
|
||||||
#include "pidref.h"
|
#include "pidref.h"
|
||||||
@@ -366,7 +367,7 @@ static void sleep_until_minimum_uptime(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
static int run(int argc, char *argv[]) {
|
||||||
static const char* const dirs[] = {
|
static const char* const dirs[] = {
|
||||||
SYSTEM_SHUTDOWN_PATH,
|
SYSTEM_SHUTDOWN_PATH,
|
||||||
NULL
|
NULL
|
||||||
@@ -402,10 +403,9 @@ int main(int argc, char *argv[]) {
|
|||||||
log_set_prohibit_ipc(true);
|
log_set_prohibit_ipc(true);
|
||||||
log_parse_environment();
|
log_parse_environment();
|
||||||
|
|
||||||
if (getpid_cached() != 1) {
|
if (getpid_cached() != 1)
|
||||||
log_error("Not executed by init (PID 1). Refusing to operate.");
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||||
return EXIT_FAILURE;
|
"Not executed by init (PID 1). Refusing to operate.");
|
||||||
}
|
|
||||||
|
|
||||||
log_set_always_reopen_console(true);
|
log_set_always_reopen_console(true);
|
||||||
|
|
||||||
@@ -668,7 +668,6 @@ int main(int argc, char *argv[]) {
|
|||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
case LINUX_REBOOT_CMD_KEXEC:
|
case LINUX_REBOOT_CMD_KEXEC:
|
||||||
|
|
||||||
if (!in_container) {
|
if (!in_container) {
|
||||||
/* Preserve fd stores via the kernel Live Update Orchestrator before kexec.
|
/* Preserve fd stores via the kernel Live Update Orchestrator before kexec.
|
||||||
* The session fd must stay open until the kexec syscall. */
|
* The session fd must stay open until the kexec syscall. */
|
||||||
@@ -706,7 +705,7 @@ int main(int argc, char *argv[]) {
|
|||||||
/* If we are in a container, and we lacked CAP_SYS_BOOT just exit, this will kill our
|
/* If we are in a container, and we lacked CAP_SYS_BOOT just exit, this will kill our
|
||||||
* container for good. */
|
* container for good. */
|
||||||
log_info("Exiting container.");
|
log_info("Exiting container.");
|
||||||
return EXIT_SUCCESS;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = log_error_errno(errno, "Failed to invoke reboot(): %m");
|
r = log_error_errno(errno, "Failed to invoke reboot(): %m");
|
||||||
@@ -717,3 +716,5 @@ error:
|
|||||||
LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN_ERROR_STR));
|
LOG_MESSAGE_ID(SD_MESSAGE_SHUTDOWN_ERROR_STR));
|
||||||
freeze();
|
freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
|
||||||
|
|||||||
Reference in New Issue
Block a user