chiark / gitweb /
logind: consider key inhibitors that are taken by non-session processes as global
[elogind.git] / src / login / logind-inhibit.c
index 2c1a412e55d9f5fcc5f57b8dc8296fadde2f240c..c43ae23acf6adf8d76b4ccf4bbe1b0510c9352ee 100644 (file)
@@ -30,6 +30,7 @@
 #include "mkdir.h"
 #include "path-util.h"
 #include "logind-inhibit.h"
+#include "fileio.h"
 
 Inhibitor* inhibitor_new(Manager *m, const char* id) {
         Inhibitor *i;
@@ -353,9 +354,14 @@ static int pid_is_active(Manager *m, pid_t pid) {
         int r;
 
         r = manager_get_session_by_pid(m, pid, &s);
-        if (r <= 0)
+        if (r < 0)
                 return r;
 
+        /* If there's no session assigned to it, then it's globally
+         * active on all ttys */
+        if (r == 0)
+                return 1;
+
         return session_is_active(s);
 }