event: tweak gpiod_simple_event_loop()
authorBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Jan 2017 12:17:01 +0000 (13:17 +0100)
committerBartosz Golaszewski <bartekgola@gmail.com>
Wed, 11 Jan 2017 12:17:01 +0000 (13:17 +0100)
If the internal system call is interrupted by a signal - just act as
if the wait timed out.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
core.c

diff --git a/core.c b/core.c
index e50a2e6518d95c0e57cc2a161357b86437086dd2..e139f22137a07ebf9c94434d56bd15a4b331ade0 100644 (file)
--- a/core.c
+++ b/core.c
@@ -277,7 +277,10 @@ int gpiod_simple_event_loop(const char *device, unsigned int offset,
        for (;;) {
                status = gpiod_line_event_wait(line, timeout);
                if (status < 0) {
-                       goto out;
+                       if (gpiod_errno() == EINTR)
+                               return evtype = GPIOD_EVENT_CB_TIMEOUT;
+                       else
+                               goto out;
                } else if (status == 0) {
                        evtype = GPIOD_EVENT_CB_TIMEOUT;
                } else {