mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-27 03:21:32 +03:00
logind: define main through macro
This commit is contained in:
parent
b453c447e0
commit
c11cfa2865
@ -1166,7 +1166,7 @@ static int manager_run(Manager *m) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
static int run(int argc, char *argv[]) {
|
||||||
_cleanup_(manager_unrefp) Manager *m = NULL;
|
_cleanup_(manager_unrefp) Manager *m = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -1179,15 +1179,12 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (argc != 1) {
|
if (argc != 1) {
|
||||||
log_error("This program takes no arguments.");
|
log_error("This program takes no arguments.");
|
||||||
r = -EINVAL;
|
return -EINVAL;
|
||||||
goto finish;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = mac_selinux_init();
|
r = mac_selinux_init();
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
log_error_errno(r, "Could not initialize labelling: %m");
|
return log_error_errno(r, "Could not initialize labelling: %m");
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Always create the directories people can create inotify watches in. Note that some applications might check
|
/* Always create the directories people can create inotify watches in. Note that some applications might check
|
||||||
* for the existence of /run/systemd/seats/ to determine whether logind is available, so please always make
|
* for the existence of /run/systemd/seats/ to determine whether logind is available, so please always make
|
||||||
@ -1199,21 +1196,16 @@ int main(int argc, char *argv[]) {
|
|||||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGHUP, SIGTERM, SIGINT, -1) >= 0);
|
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGHUP, SIGTERM, SIGINT, -1) >= 0);
|
||||||
|
|
||||||
r = manager_new(&m);
|
r = manager_new(&m);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to allocate manager object: %m");
|
return log_error_errno(r, "Failed to allocate manager object: %m");
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) manager_parse_config_file(m);
|
(void) manager_parse_config_file(m);
|
||||||
|
|
||||||
r = manager_startup(m);
|
r = manager_startup(m);
|
||||||
if (r < 0) {
|
if (r < 0)
|
||||||
log_error_errno(r, "Failed to fully start up daemon: %m");
|
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug("systemd-logind running as pid "PID_FMT, getpid_cached());
|
log_debug("systemd-logind running as pid "PID_FMT, getpid_cached());
|
||||||
|
|
||||||
(void) sd_notify(false,
|
(void) sd_notify(false,
|
||||||
"READY=1\n"
|
"READY=1\n"
|
||||||
"STATUS=Processing requests...");
|
"STATUS=Processing requests...");
|
||||||
@ -1221,11 +1213,11 @@ int main(int argc, char *argv[]) {
|
|||||||
r = manager_run(m);
|
r = manager_run(m);
|
||||||
|
|
||||||
log_debug("systemd-logind stopped as pid "PID_FMT, getpid_cached());
|
log_debug("systemd-logind stopped as pid "PID_FMT, getpid_cached());
|
||||||
|
|
||||||
(void) sd_notify(false,
|
(void) sd_notify(false,
|
||||||
"STOPPING=1\n"
|
"STOPPING=1\n"
|
||||||
"STATUS=Shutting down...");
|
"STATUS=Shutting down...");
|
||||||
|
|
||||||
finish:
|
return r;
|
||||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_MAIN_FUNCTION(run);
|
||||||
|
Loading…
Reference in New Issue
Block a user