-/* SPDX-License-Identifier: LGPL-2.1+ */
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <errno.h>
#include <fcntl.h>
#include "bus-log-control-api.h"
#include "bus-polkit.h"
#include "cgroup-util.h"
+#include "daemon-util.h"
#include "def.h"
#include "device-util.h"
#include "dirent-util.h"
seat->in_gc_queue = false;
if (seat_may_gc(seat, drop_not_started)) {
- seat_stop(seat, false);
+ seat_stop(seat, /* force = */ false);
seat_free(seat);
}
}
LIST_REMOVE(gc_queue, m->session_gc_queue, session);
session->in_gc_queue = false;
- /* First, if we are not closing yet, initiate stopping */
+ /* First, if we are not closing yet, initiate stopping. */
if (session_may_gc(session, drop_not_started) &&
session_get_state(session) != SESSION_CLOSING)
- (void) session_stop(session, false);
+ (void) session_stop(session, /* force = */ false);
- /* Normally, this should make the session referenced
- * again, if it doesn't then let's get rid of it
- * immediately */
+ /* Normally, this should make the session referenced again, if it doesn't then let's get rid
+ * of it immediately. */
if (session_may_gc(session, drop_not_started)) {
(void) session_finalize(session);
session_free(session);
User *user;
Button *button;
Inhibitor *inhibitor;
- Iterator i;
assert(m);
manager_read_utmp(m);
/* And start everything */
- HASHMAP_FOREACH(seat, m->seats, i)
+ HASHMAP_FOREACH(seat, m->seats)
(void) seat_start(seat);
- HASHMAP_FOREACH(user, m->users, i)
+ HASHMAP_FOREACH(user, m->users)
(void) user_start(user);
- HASHMAP_FOREACH(session, m->sessions, i)
+ HASHMAP_FOREACH(session, m->sessions)
(void) session_start(session, NULL, NULL);
- HASHMAP_FOREACH(inhibitor, m->inhibitors, i) {
+ HASHMAP_FOREACH(inhibitor, m->inhibitors) {
(void) inhibitor_start(inhibitor);
/* Let's see if the inhibitor is dead now, then remove it */
}
}
- HASHMAP_FOREACH(button, m->buttons, i)
+ HASHMAP_FOREACH(button, m->buttons)
button_check_switches(button);
manager_dispatch_idle_action(NULL, 0, m);
static int run(int argc, char *argv[]) {
_cleanup_(manager_unrefp) Manager *m = NULL;
+ _cleanup_(notify_on_cleanup) const char *notify_message = NULL;
int r;
log_set_facility(LOG_AUTH);
if (r < 0)
return r;
- /* 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
- * sure these directories are created early on and unconditionally. */
+ /* 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 sure these directories are created early on and unconditionally. */
(void) mkdir_label("/run/systemd/seats", 0755);
(void) mkdir_label("/run/systemd/users", 0755);
(void) mkdir_label("/run/systemd/sessions", 0755);
if (r < 0)
return log_error_errno(r, "Failed to fully start up daemon: %m");
- log_debug("systemd-logind running as pid "PID_FMT, getpid_cached());
- (void) sd_notify(false,
- "READY=1\n"
- "STATUS=Processing requests...");
-
- r = manager_run(m);
-
- log_debug("systemd-logind stopped as pid "PID_FMT, getpid_cached());
- (void) sd_notify(false,
- "STOPPING=1\n"
- "STATUS=Shutting down...");
-
- return r;
+ notify_message = notify_start(NOTIFY_READY, NOTIFY_STOPPING);
+ return manager_run(m);
}
DEFINE_MAIN_FUNCTION(run);