From 11eae36d297a7b8767abd66b53021b47ff18b4ec Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 23 Jul 2019 10:33:39 +0200 Subject: logind: at start-up automatically clean up orphaned inhibitors --- src/login/logind.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/login/logind.c') diff --git a/src/login/logind.c b/src/login/logind.c index 175db697e5..3a16e6c871 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -1145,8 +1145,15 @@ static int manager_startup(Manager *m) { HASHMAP_FOREACH(session, m->sessions, i) (void) session_start(session, NULL, NULL); - HASHMAP_FOREACH(inhibitor, m->inhibitors, i) - inhibitor_start(inhibitor); + HASHMAP_FOREACH(inhibitor, m->inhibitors, i) { + (void) inhibitor_start(inhibitor); + + /* Let's see if the inhibitor is dead now, then remove it */ + if (inhibitor_is_orphan(inhibitor)) { + inhibitor_stop(inhibitor); + inhibitor_free(inhibitor); + } + } HASHMAP_FOREACH(button, m->buttons, i) button_check_switches(button); -- cgit v1.2.1