X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flogin%2Flogind-inhibit.c;h=e77088364aa5cb352cea667610879782030543d4;hb=d98cc1c019651b895464161072894a02cc43daab;hp=2c1a412e55d9f5fcc5f57b8dc8296fadde2f240c;hpb=641906e9366891e0ad3e6e38b7396a427678c4cf;p=elogind.git diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 2c1a412e5..e77088364 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -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; @@ -291,7 +292,7 @@ int inhibitor_create_fifo(Inhibitor *i) { /* Open reading side */ if (i->fifo_fd < 0) { - struct epoll_event ev; + struct epoll_event ev = {}; i->fifo_fd = open(i->fifo_path, O_RDONLY|O_CLOEXEC|O_NDELAY); if (i->fifo_fd < 0) @@ -301,7 +302,6 @@ int inhibitor_create_fifo(Inhibitor *i) { if (r < 0) return r; - zero(ev); ev.events = 0; ev.data.u32 = FD_OTHER_BASE + i->fifo_fd; @@ -353,9 +353,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); }