main: read only one signal and only return -1 if it succeeded
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 4 Jul 2017 14:29:05 +0000 (16:29 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/main.cpp

index ba41a65..80a5c4d 100644 (file)
@@ -133,10 +133,11 @@ int main(int /*argc*/, char ** /*argv*/) {
    sigprocmask(SIG_BLOCK, &sset, nullptr);
    p.add_fd(sfd.fd, [](int fd) {
       struct signalfd_siginfo si;
-      while (read(fd, &si, sizeof(si)) == sizeof(si)) {
+      if (read(fd, &si, sizeof(si)) == sizeof(si)) {
          lognotice("Received signal %u", si.ssi_signo);
+         return -1;
       }
-      return -1;
+      return 0;
    });
 
    while ((d.flush(), p.check_events()) != -1) {